Make jquery.poptrox work on galleries which are dynamically modified via DOM #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request is changing how gallery entries are initialized and opened.
Orignally, each gallery entry was loaded to a plugin variable and onclick handler was attached to it (anchor node) during the initialization step.
This effectively disallowed further dynamic modifications of the gallery via DOM (adding more entries to the gallery, changing the captions etc.).
With commits in this PR, onclick handler is only attached to the gallery container (
$('#gallery').poptrox();
) as a delegate. Meaning that whenever any link (settings.selector
) is clicked, the event bubbles up to the container, where it is handled.To implement this, I had removed the
queue
, which was prefilled during the initialization orignally. The JS representation of a gallery entry is now being built everytime the entry is clicked (see the functionopen
).poptrox_next
andpoptrox_previous
are now reading the entries from DOM on every invocation to take into account any changes in gallery.Let me know if there are any things to discuss!
Best regards,
Tomas
Notes:
demo/demo1.html
+ some other configuration options