My favorites | Sign in
Project Home Downloads Issues
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 363: using default nyroModal class with dynamically generated links
3 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Oct 2009


 
Reported by kjau...@gmail.com, Oct 23, 2009
What steps will reproduce the problem?
1. If I dynamically generate a link with and assign the nyroModal class, 
it does not seem to know about the events attached to it.

ie if the page has something likethe following

<script>
function generateDynamicLink(itemid) {
var newLink = "<a href='somenewImage.jpg' class='nyrolink'><img 
src='thumbnail.jpg'/></a>";                
}
$(thickboxlink).appendTo("#"+itemid);
</script>

<html>
<a href="someimage" class='nyroModal'>this works just fine</a>

<div id="#1234">
New links dynamically inserted in here do NOT work
</div>

</html>







2.
3.

What is the expected output? What do you see instead?

I would expect the dynamically generated links to act the same the static 
links with nyroModal class. If I generate a nyroModal manually by 
attaching a click event WITH the .live jquery function it will perform as 
expected, but if I use a regular click event it does not work.

Is there a way to 'refresh' nyroModal when new elements are created? 



What version of the product are you using? On what operating system?

The latest version, same problem on any version of IE or FF


Please provide any additional information below.


Oct 23, 2009
#1 kjau...@gmail.com
Sorry, in the above 'nyrolink' should read 'nyroModal', that is a typo on my part
Oct 23, 2009
#2 kjau...@gmail.com
Issue solved.

An explanation was found in an earlier problem, nyroModal is initially bound when 
the page loads so new links will have to attach this. A function I used after the 
new links are generated is :

function refreshModalLinks() {
        $('a.nyroModal').nyroModal();
    };

I will add this to the wiki as it's probably common to dynamically generate 
galleries and attach links of nyroModal class.

Amazing work on this plugin, it is great and fit a lot of needs that others just 
couldn't quite get to that I tried. Thanks again
Oct 24, 2009
Project Member #3 nyro...@gmail.com
Thanks for sharing your solution.

I just added a page in the wiki to archive it:
http://nyromodal.nyrodev.com/wiki/index.php/Deal_with_dynamically_generated_links
Status: Fixed
Sep 2, 2010
#4 darthfi...@poczta.onet.pl
Hmmm... can't nyroModal use delegate() so that the new links will get it's instance of nyroModal automatically?

Powered by Google Project Hosting