Hi,
I’ve been playing with CJuiAutoComeple modifying how it presents the results and so far I’ve been able to achieve everything I wanted however I have a problem and a question which I hope someone might know the answer here,
My code looks like this:
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>'toplivesearch',
'source'=>$this->createUrl('/site/autocompleteTest'),
'options'=>array(
'minLength' => '3',
'change' => 'js: function(event, ui) {
console.log("Change Event");
//dummy code
$("#close-result").on("click",function(){
alert("hey");
});
//end dummy code
}',
),
'htmlOptions'=>array(
'placeholder'=>'Search',
'class'=>'search-box',
'size'=>'26',
)
));
During the “change” event I want to be able to detect if an anchor is clicked, what happens is, “open” event opens the result window which has a close button, however as soon as I click on close the change event triggers and ignores my click, I’ve tried different approches with so successes, read bind() documentation and tried to implement it as well with no luck, any idea how I can do this?
Also, my javascript code turned out to be too big, this widget is basically about 2 pages long now with all the javascript codes, is there anyway to separate the javascript from this widget and make it an external file? that would also benefit me since I can use functions more easily and get rid of duplicated codes in different events.
Appreciate your help
Nick