How do you populate the lightbox using Ajax? Does the element have to have data attributes or can you define it in the JS script? Or can it do both?
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.
The elgg/lightbox module lets you do either. Set data-colorbox-opts on the element, or pass them to the open() method. Here's the Colorbox docs.
It's pretty straightforward to use an ajax view URL as an href.
Ah I see, I can also set parameters in the href right?
href can be a URL (with querystring) or just "#fragment" pointing to some element in the current page.
Edit: never mind, found the code in embed plugin:
How do I load the lightbox using JS? I can populate it using just the href but if the page doesn't load completely and when you click on the link, it takes me to a bad request page.
I'm not understanding you. Look at what mod/reportedcontent does. It uses a regular page handler to send just the form if the request is XHR. Then the menu item just points to it with elgg-lightbox as the link_class.
The likes count link uses the data- attribute and an ajax view to send the content.
FWIW, unless you provide a full page version of the content (reported content does), it's better to set the link to javascript: and set the colorbox href. It eliminates the possibility of the user ending up stuck on a fragment page with no navigation/css/etc.
My link looks like this with the href having the pound symbol:
It's working so far for the other links.
It looks like it's working. Since the colorbox content is in an iframe you will need to add target="_top" to any links and to the form element.
What's the difference if I don't add the target attribute?
- Previous
- 1
- 2
- Next
You must log in to post replies.