Page 1 of 1

Best way to load content with ajax, cmsmms1.11

Posted: Tue Jul 31, 2012 7:40 pm
by uloloi
Hi guys! Amazing the new version! Right now I´m making my poor tests

I have a few doubts -from many time ago-: What is the best way to load content with ajax? Or even, is load ajax content a bad practice to navigate over the web sites? showtemplate=false doesn´t exist in the v 1.11 ?

Re: Best way to load content with ajax, cmsmms1.11

Posted: Tue Jul 31, 2012 8:56 pm
by uloloi
Well, I just ask and answer to myself, haha!

And I find this solution to my purpose:

Code: Select all

$(document).ready(function($){

	var tmp = $("#content").html();
	$(".NewsSummary a").click(function(e){
		e.preventDefault();
		// var tmp = $("#content").html();
		var goTo = $(this).attr('href');
		// alert(goTo);
		// ./index.php?mact=News,cntnt01...blah...&showtamplate=false
		
		$("#content").load(goTo+'&showtemplate=false', function(){
			$('<p id="byenews"><a href="#">Quitar Noticia</a></p>').appendTo('#content');
			$("#byenews a").click(function(e){
				e.preventDefault();
				$("#content").empty().html(tmp);
			});
		});
	});

});
And just to reaffirm, Does using showtemplate = false is right to use ajax?

Re: Best way to load content with ajax, cmsmms1.11

Posted: Mon Feb 25, 2013 3:31 pm
by velden
I was wondering, in addition to this question, whether it is possible to load the content of multiple content blocks.

As far as I know, only the contents of the default {content} block is returned when using showtemplate=false.

I often use multiple content blocks in my templates.

Re: Best way to load content with ajax, cmsmms1.11

Posted: Mon Feb 25, 2013 4:42 pm
by calguy1000
No, there's no way I know of to load the content of additional content blocks at this time.

Re: Best way to load content with ajax, cmsmms1.11

Posted: Tue Feb 26, 2013 1:58 am
by applejack
Using jQuery load you can load content from a selector to a selector.