Colorbox for Ajax-loaded page. Problem of Yii?

Hi,guyes,

I use ajax tabs provided by jQuery to load different pages into one. Inside one of these pages, I have some links which I want them to be opened using colorbox. These links are all under the class of “iframe”. In the parent page, I used the following code. Although lots of people provided solution like this, and the author also claims the following should work, it didn’t work. I doubt if it’s a problem of Yii. Can anyone help on this? Thank you so much!


 $(document).ready(function(){

          $('.iframe').live('click',function(e){

             e.preventDefault();

             $.fn.colorbox({href:$(this).attr('href'), open:true});

         })


 })

Anyone?

This code looks OK…

Check the source of the rendered page if there is that code…

Check with firebug if that code is executed…

I put an alert function inside. It works fine. But the statement for colorbox didn’t run…

I’m sure I included colorbox.js and colorbox.css.

Check the source of the generated page if there is the colorbox.js included… if it is… could be a case sensitivity problem…

I did not use colorbox() yet… but just took a look at it’s page - http://jacklmoore.com/colorbox/

Notice under usage that they use $.colorbox(…) and you used $.fn.colorbox(…)

I use “$.fn.colorbox” because “.colorbox” didn’t work, and this was suggested by the author.

But it’s not working becasue your error say “Object has no method colorbox()”…

Did you check that the generated page is including the colorbox.js ?

If yes… I would suggest you to create a simple HTML page and add the colorbox there to see if it works…