0

I am using CListView widget (yii framework) like this:

<?
    $this->widget('zii.widgets.CListView', array(
        'dataProvider'=>$dataProvider,
        'itemView'=>'_view',
        'template'=>"{items}\n{pager}",
    )); 
    ?>

I have few button in "_view" and a process.js file where I have attached click event with buttons like this:

 $(document).ready(function(){
        $("a#beerButton").click(function(){
            alert('clicked');
        });
    
   });

They are working fine in initial page display but after ajax update (Clistview pagination to view next page), no button is responding. What is causing the problem. Shall I have to include the js files again on update.

EDIT:


on() event solved the problem :) Its working now. Reference

3
  • where is your process.js? i mean how did you include it in the view and in which file? Commented Feb 10, 2012 at 11:47
  • I have included the process.js in the main file (common file in yii applications). Commented Feb 10, 2012 at 11:57
  • 1
    This solved the problem stackoverflow.com/questions/2892244/… Commented Feb 10, 2012 at 11:57

2 Answers 2

1

you should try this

$(document).ready(function(){
        $("a#beerButton").live('click', function(){
            alert('clicked');
        });

   });
Sign up to request clarification or add additional context in comments.

1 Comment

I have already mentioned it in comments. Anyway delegate() is preferred method.
0

check your js code some")" and "}" are missing use fire bug to avoid these sort of probs...

1 Comment

I have confirmed for syntax error in Chrome (Developer Tools). It is correct. Further it is working fine initially.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.