Dynamic block loading
Permalink<script>
$(document).ready(function() {
$(".testButton").click(function(){
$('#loadIntoThisDiv).load('urlWhereTheInformationToBeLoadedResides #specificDivIdToExtractFrom');
});
});
</script>
..This is sorted out and works fine. However, I'd like that page which is being pulled in to have some buttons on the side and also pull in data dynamically. This works on the page itself but fails to work when already being pulled in. Does this make any sense at all? ...it's as if I'm missing something with this secondary set of scripts...
One of my first posts so describing the technical issues is a little difficult right now.
cheers,
On Monday, May 19, 2014 2:16 PM, concrete5 Community <discussions@concretecms.com> wrote:
Thanks
How do I dynamically load javascripted blocks?
Believe you me, I'm actually trying to explain this as best as possible.
Cheers and thanks,
Bjorn
There's an add-on in the marketplace called Rapid Ajax Paging that would allow you to load a page in a container using ajax (which is what it seems you're trying to do)
You can find it herehttp://www.concrete5.org/marketplace/addons/rapid-ajax-paging/...
I worked with it and it's pretty good. Also if you're goal is to learn rather to quickly reach the goal, I still suggest you buy it and have a look at the code as well as code from another add-on called Blocks by Ajax (http://www.concrete5.org/marketplace/addons/blocks-by-ajax/) that loads only blocks not whole pages.
Thanks for information,
Bjorn
When the secondary content gets loaded, the document.ready event has already fired, so if you have code like this within that content it's not going to be executed.
The best way to do this is to add the code you want to execute as the last parameter of the "load" function. Seehttp://stackoverflow.com/questions/8939127/jquery-executing-javascr...
However if your dynamic content can change or is fairly complicated, this may not be feasible. You could try just adding the code you want to run to a script tag at the end of the content and NOT wrapping it in the document.ready event, so it executes as soon as the content is inserted into the page. Just make sure the script tag is at the very end of your dynamic content, otherwise it will execute before the HTML part of the content has been inserted into the page.