Hello, I am facing up a strange issue when trying to load a JS on a lightbox view.
On lightbox is loaded a view using the "elgg_view('my_plugin/my_plugin_view', $vars)".
On this view there is the following:
elgg_require_js('my_plugin/my_plugin_js');
When click on the button to open the lightbox, the my_plugin_js.js is loaded on the popup window without issues. But if close the lightbox and open it again the my_plugin_js.js in not loaded.
If refresh the page and click again on the same button, it works fine but not if close and re-open the lightbox.
The Elgg version is 3.3.17.
Any ideas what could be wrong or missing?
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 1 like
- nikos@nlyberakis
nikos - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
This will load your JS when lightbox is open
- Steve Clay@steve_clay
Steve Clay - 0 likes
- nikos@nlyberakis
nikos - 0 likes
You must log in to post replies.AJAX in action ;)
Simple way is to extend your view with this JS:
where 'my_plugin/my_plugin_js' is a PHP file not JS:
You can add JS into your view directly as well.
Thanks @Nikolai
Even I wanted to avoid JS inside php, it worked
You can use JS event on open lightbox:
Your general problem is code in a module executes once. It sounds like your module should add an event listener for when colorbox opens. Just curious, what does that code do?
@Steve Clay: the code generates a paypal button. So it may have different values, e.g. cost on each popup open.
But the JS is not loaded after 1st popup, even if it has a simple command such as "console.log".