Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Execute Javascript from backend


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 4 - Last Post: Jan 12, 2017 7:06 AM Last Post By: Pedro Lopes
Michael Schumann

Posts: 28
Registered: 11/5/99
Execute Javascript from backend  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 10, 2017 4:39 AM
I face the following problem:

In my application I use a main form loading frames with different functions into a region. The frames are created in a singleton manner (for each session). This works well and helps to save resources as frames are only created once and only if the session requires it. I have one frame loading static html content from a file as my application serves as a internet site too. This also works fine but I don't know how to realize this:

I have on big page with static HTML content (bootstrap accordeon) and would like to focus different parts of the page on selection of the main menu. As I always have to create (if required) and load the frame before the content ist present I cannot use a pure javascript event. What I would need is a function that executes some defined javascript AFTER loading the frame from code.

Edited by: Michael Schumann on Jan 10, 2017 4:56 AM

Edited by: Michael Schumann on Jan 10, 2017 4:57 AM
Guest
Re: Execute Javascript from backend
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 10, 2017 6:30 AM   in response to: Michael Schumann in response to: Michael Schumann
Michael Schumann wrote:
I face the following problem:

In my application I use a main form loading frames with different functions into a region. The frames are created in a singleton manner (for each session). This works well and helps to save resources as frames are only created once and only if the session requires it. I have one frame loading static html content from a file as my application serves as a internet site too. This also works fine but I don't know how to realize this:

I have on big page with static HTML content (bootstrap accordeon) and would like to focus different parts of the page on selection of the main menu. As I always have to create (if required) and load the frame before the content ist present I cannot use a pure javascript event. What I would need is a function that executes some defined javascript AFTER loading the frame from code.

Edited by: Michael Schumann on Jan 10, 2017 4:56 AM

Edited by: Michael Schumann on Jan 10, 2017 4:57 AM

Hi, Are you using templates?

Any way, you can put the next code:
<html>
<body>
...
 
...
..
 
 
<script type="text/javascript">
      $(document).ready(function()  {
          //execute your function  
 </script>
</body>
<html>


Edited by: Luiz Oliveira on Jan 10, 2017 6:33 AM

Edited by: Luiz Oliveira on Jan 10, 2017 6:34 AM
Michael Schumann

Posts: 28
Registered: 11/5/99
Re: Execute Javascript from backend  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 10, 2017 7:00 AM   in response to: Guest in response to: Guest
Thanks, but this doesn't solve my problem as the menu options each have a delphi event creating the frame and loading the html content (if required), and assigning it to the master region. As it is always the same content and it is only loaded on creation of the frame I cannot use javascript code embedded in the document.

I did some more research and found WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA(js); to add a javascript call to the current ajax response. This might be the way to solve my problem - I will try it as soon I get back to my desk and post the solution here if it works.
Guest
Re: Execute Javascript from backend
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 10, 2017 7:45 AM   in response to: Michael Schumann in response to: Michael Schumann
Michael Schumann wrote:
Thanks, but this doesn't solve my problem as the menu options each have a delphi event creating the frame and loading the html content (if required), and assigning it to the master region. As it is always the same content and it is only loaded on creation of the frame I cannot use javascript code embedded in the document.

I did some more research and found WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA(js); to add a javascript call to the current ajax response. This might be the way to solve my problem - I will try it as soon I get back to my desk and post the solution here if it works.

An option will be use delegate in JS:
In my code I use in document onReady:
$("#menu_item").on('click', '#item1',function(){
                    var pid = $(this).attr('data-id');
                    executeAjaxEvent("&data="+pid, null,"OnMenuItemClick",false, null, false);
                    
              });


Using it, the menu, buttons .... dont' need be created before. The click will be delegate and only be executed if the item exists.

You need to create and register "OnMenuItemClick" or other name into IWForm

Edited by: Luiz Oliveira on Jan 10, 2017 7:45 AM
Pedro Lopes

Posts: 97
Registered: 3/2/00
Re: Execute Javascript from backend  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 12, 2017 7:06 AM   in response to: Michael Schumann in response to: Michael Schumann
Michael Schumann wrote:
Thanks, but this doesn't solve my problem as the menu options each have a delphi event creating the frame and loading the html content (if required), and assigning it to the master region. As it is always the same content and it is only loaded on creation of the frame I cannot use javascript code embedded in the document.

I did some more research and found WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA(js); to add a javascript call to the current ajax response. This might be the way to solve my problem - I will try it as soon I get back to my desk and post the solution here if it works.

Hello Michael

Do you want to add html correspondent to the frame to the current html page @ the master region?

You can do this using cgdevtools RenderAsync methods, stepping the advertise :)

Best, PL
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02