Best way to load content with ajax, cmsmms1.11

General project discussion. NOT for help questions.
Post Reply
uloloi
Forum Members
Forum Members
Posts: 88
Joined: Thu Dec 16, 2010 8:50 pm

Best way to load content with ajax, cmsmms1.11

Post 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 ?
uloloi
Forum Members
Forum Members
Posts: 88
Joined: Thu Dec 16, 2010 8:50 pm

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

Post 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?
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

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

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

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

Post by calguy1000 »

No, there's no way I know of to load the content of additional content blocks at this time.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
applejack
Power Poster
Power Poster
Posts: 1015
Joined: Fri Mar 30, 2007 2:28 am
Location: London

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

Post by applejack »

Using jQuery load you can load content from a selector to a selector.
Post Reply

Return to “General Discussion”