Popup on page load
Permalink Browser Info Environment
Great add on! Is there a way to make popups automatically display on page load?
I've tried triggering a click with jquery but it's not working.
Any help appreciated.
I've tried triggering a click with jquery but it's not working.
Any help appreciated.
Type: | Ticket |
---|---|
Status: | Resolved |
Thanks for getting back to me. I ended up using a different add-on (Stack Popover I think from memory) as I was under some time pressure.
I have another site in progress that I'll use this licence of Buttons Pro for. It's such a great add-on.
For future reference, how would you call a popover on pageload? I had a separate html block with some javascript that was trying to target the button link on page ready and hitting it with a click() but it wasn't firing. Clunky I know, but this was an old site that I hadn't touched on for years.
I also tried wrapping it in a custom class and getting to it that way to no avail.
I had a bit of a dig through the controller and created a custom view but couldn't see where the magnificPopup code was being inserted. My initial thought was to just call the open method on that on pageload.
In any case, my client wanted to be able to add popups themselves in future and the other add on was a bit simpler.
I have another site in progress that I'll use this licence of Buttons Pro for. It's such a great add-on.
For future reference, how would you call a popover on pageload? I had a separate html block with some javascript that was trying to target the button link on page ready and hitting it with a click() but it wasn't firing. Clunky I know, but this was an old site that I hadn't touched on for years.
I also tried wrapping it in a custom class and getting to it that way to no avail.
I had a bit of a dig through the controller and created a custom view but couldn't see where the magnificPopup code was being inserted. My initial thought was to just call the open method on that on pageload.
In any case, my client wanted to be able to add popups themselves in future and the other add on was a bit simpler.
Personally, I would have done what you did and try to trigger a click on the button.
I would have created a template for the block, copying the code from the normal block's view. I would have put my JS code in the template right after the button code.
It might be better to select a link element instead of a button element for the button.
This is untested, though, I just can't imagine why it wouldn't work.
If you look through the block's view.php I left comments explaining how you can customize the button output from code. One thing you can do, as explained in my comments, is grab the full button markup and modify it before outputting it to the page. You could do that and modify it as you please but frankly it seems overkill for your purpose.
I would have created a template for the block, copying the code from the normal block's view. I would have put my JS code in the template right after the button code.
It might be better to select a link element instead of a button element for the button.
This is untested, though, I just can't imagine why it wouldn't work.
If you look through the block's view.php I left comments explaining how you can customize the button output from code. One thing you can do, as explained in my comments, is grab the full button markup and modify it before outputting it to the page. You could do that and modify it as you please but frankly it seems overkill for your purpose.
Thanks. Yeah, I did make a new template for the block and started messing around with it but my client needed something easier to manage going forward. Your add on was the first one that came up when I searched C5 Popup :-)
I appreciate the support though. Thanks again.
I appreciate the support though. Thanks again.
It should work, really. Could you show me the code you used and if possible the page where the popup is, so I can run some tests?