Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Refresh template
#1
My case:  

with THandlers.Add('', 'form1', TContentForm.Create(TForm1)) do
  begin
    CanStartSession := true;
    RequiresSessionStart := false;
 end;


with THandlers.Add('', 'form2', TContentForm.Create(TForm2)) do
  begin
    CanStartSession := true;
    RequiresSessionStart := false;
 end;


Both Forms have mastertemplate.html. I this template dynamic Javascript in div create Bootstrap mega menu depending of language user. 
mastertemplate.html <div id="menu"></div>  

WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA fill this div with timer in tform1 and tform2. This work. I can not refresh this template OnCreate or OnShow thats why timer in form.
<div id="menu">
<ul>
      <li><a href="form1">Form1</a></li>
      <li><a href="form2">Form2</a></li>
</ul>
</div>

RefreshTemplate function is define in UserSession and run in timer individual form.

If i have open Form1 and click again link to form1 then load mastertemplate empty div for menu!

Is a change only refresh mastertemplate for all forms?
Reply
#2
Hi, you can send directly to your id, something like this:
Code:
WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA(
  'document.getElementById("menu").innerHTML = "' +
  'all_your_html_here' +
  '"'
);
In all_your_html_here, pay attention to DON'T use double quotes inside. If you need double quotes, use single quotes doubled. Because all_your_html_here need inside the double quotes of getElement.
Reply
#3
(09-15-2021, 02:30 PM)Jose Nilton Pace Wrote: Hi, you can send directly to your id, something like this:
Code:
WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA(
  'document.getElementById("menu").innerHTML = "' +
  'all_your_html_here' +
  '"'
);
In all_your_html_here, pay attention to DON'T use double quotes inside. If you need double quotes, use single quotes doubled. Because all_your_html_here need inside the double quotes of getElement.

So it already works! This is not problem. Have to change my mastertemplate.html in usersession before create and show my form with my exist refresh function.
Template is not completed because user language.
Have easy access to my mastertemplate.html that usersession with my Refresh function (include AddJavaScriptToExecuteAsCDATA)?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)