herun1988
(Herun1988)
October 10, 2011, 12:33am
1
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});
})
})
mdomba
(Maurizio Domba Cerin)
October 10, 2011, 11:41am
3
This code looks OK…
Check the source of the rendered page if there is that code…
Check with firebug if that code is executed…
herun1988
(Herun1988)
October 10, 2011, 3:42pm
4
I put an alert function inside. It works fine. But the statement for colorbox didn’t run…
herun1988
(Herun1988)
October 10, 2011, 3:55pm
5
I’m sure I included colorbox.js and colorbox.css.
mdomba
(Maurizio Domba Cerin)
October 10, 2011, 5:29pm
6
Check the source of the generated page if there is the colorbox.js included… if it is… could be a case sensitivity problem…
mdomba
(Maurizio Domba Cerin)
October 10, 2011, 5:31pm
7
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(…)
herun1988
(Herun1988)
October 11, 2011, 1:27am
8
I use “$.fn.colorbox” because “.colorbox” didn’t work, and this was suggested by the author.
mdomba
(Maurizio Domba Cerin)
October 11, 2011, 8:03am
9
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…