jquery timeago plugin and jquery corner plugin don't work with dynamic content
I have a list of reviews, and when you add a review it posts to a PHP page and then loads a Smarty template into the beginning of the review list to show the review you just posted.
That works fine. However, I use a rounded corners plugin and timeago on the review post. I tried re-calling these functions after it loads the review, but that doesn't work either.
I am aware that using .live is approprite for fixing this problem in many other cases, but I don't know how I could apply that here. jquery's .live only works on events. What is the event here?
Any ideas?
For reference: jquery timeago plugin: http://timeago.yarp.com/ jquery corner plugin: http://www.methvin.com/jquery/jq-corner-demo.html
--
As reques开发者_开发技巧ted, here is some elaboration: I use $.load to load the template content into the div area. There are no errors from this. It works perfectly, with the exception of the timeago/corner plugins not affecting the output.
I don't have the code accessible to me right now, but it goes a little something like this:
$.load('/inc/templateLoader.php?tpl=reviews');
$('abbr.timeago').timeago();
$('.corner').corner();
Some people have suggested it might not be working because $.load can complete before the page loads, which would cause the issue I am experiencing.
For those interested, the problem was that the page wasn't finished loading when I was re-applying the corner and timeago effects. I solved the problem by using $.get and then re-applying the corner/timeago stuff inside of the success callback.
Firefox and the Firebug plugin are your friends. Install, reload the page, and look at the errors on the console tab.
精彩评论