Open myoldusername opened 6 years ago
Pass false for the rest of the sections?
you have to sort each section in the page to disable it which may take long time , is there any easy way !
I'm not entirely sure what you're asking, and how you would like to do it instead. Can you give me an example?
Some time a part of the page has ajax call an i want to call same page but with GET parm referring to the section i want to render.
Well i came up with a solution , the Render now is a function like this :
in HTML i name the section like
{{#ajax_section}}
.............
{{/ajax_section}}
{{# section_1 }}
.......
{{/ section_1 }}
{{# section_2 }}
.......
{{/ section_2 }}
{{# section_3 }}
.......
{{/ section_3 }}
now in the php page i manage some logic . if $section
passed then just render this section.
function printTemplate($mustache, $templateName, $context, $section = null)
{
if (!empty($section))
{
$tpl = $mustache->getLoader()->load($templateName);
preg_match_all("~{{# *$section *}}(.*?){{/ *$section *}}~is", $tpl, $match);
$mustache->setLoader(new Mustache_Loader_StringLoader);
echo $mustache->render($match[1][0], $context) ;
}
else
{
$tpl = $mustache->loadTemplate($templateName);
echo $tpl->render($context);
}
}
Variables are false by default. Did you try just passing in the section you wanted to render as true?
well the problem is :
{{#ajax_section}}
Here there is a lot of Variables , so i have to chose them one by one !
e.g {{username}} {{location}}
If i pass Only ajax_section , then all other vars will not rendered !
{{/ajax_section}}
Hey, this is probably some gravedigging and you probably don't have this problem anymore, but I just solved it (in a bad way I guess) and this could help people in the future that stumble upon this thread like me.
I also wanted to only update a part of my mustache-tempalte and not the whole thing (because this would fu** up my javascript and I had to rerun it, resulting in an endless loop...).
My solution incorporates the usage of jquery on the resulting html string and then only replacing said data-region:
templates.render('tool_supporter/course_table', data).done(function(html, js) {
// Get the data-region of the rendered html
var anchor = $('[data-region="course_filtering"]', $(html));
// Only render the filtering dropdown of the tables.
$('[data-region="course_filtering"]').replaceWith(anchor[0].outerHTML);
}).fail(notification.exception);
Dear all Let say i have this html:
how can i chose to render only
section_2