Answer the question
In order to leave comments, you need to log in
How to call javascript function in Yii in Jquery zone?
Good afternoon,
There is a problem with calling js code.
There is this piece in the view:
Listing 1:
1. If I call pium(), it executes, but in turn does not see the tadam() function.
2. In the main theme file main.php, the scripts.js file is included in the footer:
<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.'/js/scripts.js');?>
$(document).ready(function()
{
function func()
{
alert("hello");
}
});
<?php $this->widget('zii.widgets.jui.CJuiAutoComplete',
[
'name'=>'name',
'value'=>'',
'source'=>Yii::app()->createUrl('hotels/autocomplete'),
'options'=>
[
'showAnim'=>'fold',
'minLength'=>'3',
'select'=>'js:function( event, ui )
{
$("#nameSearch").val( ui.item.label );
$("#nameValue").val( ui.item.label );
// $("#nameID").val( ui.item.id );
// Поиск отеля
// searchHotel();
pium();
return false;
}',
],
'htmlOptions'=>
[
'onfocus' => 'js: this.value = null; $("#nameValue").val(null); $("#selectedvalue").val(null);',
'class' => 'input-xxlarge search-query',
'name' => 'Hotels[name]',
'placeholder' => "Введите первые 3 и более названия",
'id'=>'nameSearch'
],
]);
?>
Answer the question
In order to leave comments, you need to log in
$(document).ready(function()
{
function func()
{
alert("hello");
}
});
$(document).ready
or do window.func = function () {}
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question