Yii Framework Forum: Jquery(...).alert Is Not A Function[Solved] - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Jquery(...).alert Is Not A Function[Solved] Rate Topic: -----

#1 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 261
  • Joined: 15-August 12

Posted 24 December 2013 - 11:18 PM

Hi friends,
I have in main layout following scripts:
	<?php Yii::app()->clientScript->registerCoreScript('jquery') ?>
	<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/main.js") ?>
	<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/requirements.js") ?>
	<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/jquery.cookie.js") ?>
	<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/jquery.blockUI.js") ?>
	<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/ckeditor/ckeditor.js") ?>
	<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/jquery.animate-shadow.js") ?>

On ajax request i do:
$this->renderPartial('index',array('dataProvider'=>$dataProvider),false,true);

but encountered with this error:
$(...).unblock is not a function

I noticed some JS files don't render on ajax requests. So i try this(register scripts in begin action):
	public function actionIndex($cat=null, $subCat=null)
	{
    	if(Yii::app()->request->isAjaxRequest){
            Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/main.js");
            Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/requirements.js");
            Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/jquery.cookie.js");
            Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/jquery.blockUI.js");
            Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/ckeditor/ckeditor.js");
            Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/jquery.animate-shadow.js");
    	}
    	.
    	.
    	.   


know is no problem with custom scripts bu is there problem with jquery:
jQuery(...).alert is not a function

whats the reason?
0

#2 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 261
  • Joined: 15-August 12

Posted 25 December 2013 - 10:50 AM

I noticed the problem is in following block code:
<?php if(Yii::app()->user->hasFlash('Warning')): ?>
	<div style="margin:150px">
	<?php $this->widget('bootstrap.widgets.TbAlert', array(
			'block'=>true, // display a larger alert block?
			'fade'=>true, // use transitions?
			'closeText'=>'&times;', // close link text - if set to false, no close link is displayed
			'alerts'=>array( // configurations per alert type
				'Warning'=>array('block'=>true, 'fade'=>true, 'closeText'=>false), // success, info, warning, error or danger
			),
		));	
	?>
	</div>
<?php else: ?>

When rendering this widget on following lines the error throw out:
TbAlert:
		/** @var CClientScript $cs */
		$cs = Yii::app()->getClientScript();
		$cs->registerScript(__CLASS__ . '#' . $id, "jQuery('{$selector}').alert();");

		foreach ($this->events as $name => $handler) {
			$handler = CJavaScript::encode($handler);
			$cs->registerScript(
				__CLASS__ . '#' . $id . '_' . $name,
				"jQuery('{$selector}').on('{$name}', {$handler});"
			);
		}

when registering above scripts.

I'm looking for solution.
0

#3 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 261
  • Joined: 15-August 12

Posted 25 December 2013 - 11:20 AM

Problem was in registering bootstrap.min.js. with adding below code:
Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/bootstrap.min.js");

In begin controller action, on ajax requests solved.
		if(Yii::app()->request->isAjaxRequest){
			Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/main.js");
			Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/requirements.js");
			Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/jquery.cookie.js");
			Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/jquery.blockUI.js");
			Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/ckeditor/ckeditor.js");
			Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/jquery.animate-shadow.js");
			Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl."/js/bootstrap.min.js");
		}

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users