-
AuthorPosts
-
wdiggles Friend
wdiggles
- Join date:
- March 2011
- Posts:
- 41
- Downloads:
- 34
- Uploads:
- 9
- Thanks:
- 8
- Thanked:
- 5 times in 3 posts
September 14, 2017 at 8:00 pm #1062168Hello,
Is it possible to trigger custom scripts when JA Megafilter loads? I am trying to get the items to open in a modal window when clicked.
The modal plugin I use is Modals by Regular Labs. This is what he had to say about the topic:
That JA Megafilter seems to load the results via ajax. So these links are not in the content the moment Modals gets to look at the content. For this to work, JA Megafilter would have to trigger the Modals initialization script every time it pushes new content to the page.
The script that needs to be triggered:
RegularLabsModals:init();
Is this possible with JA Megafilter? or is there any other way to get the items to open in a modal window?
Thanks!
WarrenMr.Cat ModeratorMr.Cat
- Join date:
- December 2016
- Posts:
- 270
- Downloads:
- 24
- Uploads:
- 69
- Thanks:
- 58
- Thanked:
- 53 times in 50 posts
September 15, 2017 at 2:03 am #1062215You can use one of two events to trigger your custom script. Try and let me know if it works 🙂
jQuery(document).on('afterRender', function (e) { #Your code goes here! });
or
jQuery(document).on('afterUpdateRender', function (e) { #your code goes here })
- This reply was modified 7 years, 3 months ago by Mr.Cat.
- This reply was modified 7 years, 3 months ago by Mr.Cat.
Wisdom is not a product of schooling but of the lifelong attempt to acquire it.
wdiggles Friendwdiggles
- Join date:
- March 2011
- Posts:
- 41
- Downloads:
- 34
- Uploads:
- 9
- Thanks:
- 8
- Thanked:
- 5 times in 3 posts
September 15, 2017 at 2:28 pm #1062310Hello,
Thank you for your reply. What file do I need to add the code to? And where?
Is this exactly how the code should be written?
jQuery(document).on('afterRender', function (e) { RegularLabsModals:init(); });
Thanks!
WarrenMr.Cat ModeratorMr.Cat
- Join date:
- December 2016
- Posts:
- 270
- Downloads:
- 24
- Uploads:
- 69
- Thanks:
- 58
- Thanked:
- 53 times in 50 posts
wdiggles Friendwdiggles
- Join date:
- March 2011
- Posts:
- 41
- Downloads:
- 34
- Uploads:
- 9
- Thanks:
- 8
- Thanked:
- 5 times in 3 posts
September 18, 2017 at 2:13 pm #1062684Hello,
Thank you again for your help on this, but it is not working yet. This is what is happening:
I added the code at the end of this file right before the /script tag:
/plugins/jamegafilter/content/tmpl/default.php ... jQuery(document).ready(function() { var UBLNConfig = {}; UBLNConfig.dataUrl = "<?php echo JUri::base(true).$this->config->json; ?>"; UBLNConfig.fields = <?php echo json_encode($this->config->fields); ?>; UBLNConfig.sortByOptions = <?php echo str_replace('.value','.frontend_value',json_encode($this->config->sorts)); ?>; UBLNConfig.defaultSortBy = "<?php echo $this->config->default_sort; ?>"; UBLNConfig.productsPerPageAllowed = [<?php echo implode(',', $this->config->paginate); ?>]; UBLNConfig.autopage = <?php echo $this->config->autopage ? 'true':'false' ?>; UBLNConfig.sticky = <?php echo $this->config->sticky ? 'true':'false' ?>; UBLN.main(UBLNConfig); MegaFilterCallback(); }); jQuery(document).on('afterUpdateRender', function (e) { RegularLabsModals:init(); }); </script>
I started with ‘afterRender’ in the script but that breaks something and the page is blank. I changed it to ‘afterUpdateRender’ and the page renders like it is supposed but still the modal links do not work.
Mr.Cat ModeratorMr.Cat
- Join date:
- December 2016
- Posts:
- 270
- Downloads:
- 24
- Uploads:
- 69
- Thanks:
- 58
- Thanked:
- 53 times in 50 posts
wdiggles Friendwdiggles
- Join date:
- March 2011
- Posts:
- 41
- Downloads:
- 34
- Uploads:
- 9
- Thanks:
- 8
- Thanked:
- 5 times in 3 posts
September 20, 2017 at 1:34 am #1062986Hello,
I asked Peter at RegularLabs to explain what is happening when the custom script is triggered and this is what he said:
"Essentially that script searches through the DOM for links that should be handled as modal links and adds the correct functionality to those links."
He also realized that the original code he sent me had a typo, it should have a period before init not a comma.
jQuery(document).on('afterRender', function (e) { RegularLabsModals.init(); });
I tried adding the correct code to the default.php file but it still doesn’t work. On a positive note, the afterRender option does not break the page anymore.
Thanks!
WarrenMr.Cat ModeratorMr.Cat
- Join date:
- December 2016
- Posts:
- 270
- Downloads:
- 24
- Uploads:
- 69
- Thanks:
- 58
- Thanked:
- 53 times in 50 posts
September 20, 2017 at 3:45 am #1063018As i see, RegularLabsModals uses Colorbox js to create modal. You can use Colorbox js also.
But in my opinion, if you’re not familar with javascript, you should hire some one to help you. It takes a lot of works even with me. That’s the reason why event ‘afterRender’ does not solve any thing ( my bad ).
Wisdom is not a product of schooling but of the lifelong attempt to acquire it.
wdiggles Friendwdiggles
- Join date:
- March 2011
- Posts:
- 41
- Downloads:
- 34
- Uploads:
- 9
- Thanks:
- 8
- Thanked:
- 5 times in 3 posts
September 22, 2017 at 2:26 am #1063437Hello,
It turns out we were on the right track. Instead of adding the code directly to the default.php file we added it to the custom javascript field of the template area in the admin.
jQuery(document).on('afterRender', function (e) { RegularLabsModals.init(); });
We also added an additional .modal_link class to the links in the product-item.php file.
Hope that helps someone else out there.
Thank you again for the help!
1 user says Thank You to wdiggles for this useful post
-
AuthorPosts
This topic contains 9 replies, has 2 voices, and was last updated by Mr.Cat 7 years, 3 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum