function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
neao18neao18 

Push javascript into page from controller?

hi how can we push a js from contoller to page??

I mean how to add js dynamically to page

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

The way I'd handle this is to have the javascript in the page, but don't render it until the case is created.

 

Once you create the case, if you rerender the section with the javascript in it, the case information will then be available to that javascript.

 

There's an example of delayed rendering of javascript on my blog at:

 

http://bobbuzzard.blogspot.co.uk/2011/05/refreshing-record-detail-from-embedded.html

 

and an example of retrieving information from another object after the page load, and then using that in a rerender at:

 

http://bobbuzzard.blogspot.co.uk/2011/11/retrieve-related-object-fields.html

All Answers

bob_buzzardbob_buzzard

Can you explain a little more about what you are trying to do?  Generating javascript server side is quite an unusual requirement!

 

neao18neao18

Hi Bob,

 

What my requirment is that I am creating a case and after its inserted I want its case Id,Case No, Subject field to be shown in a jquery BlockUI message box.

But the problem is that after its created and the page is loaded the variable in my controller that holds the data is not binding put to my page so I am unable to get the values.

 

So what I am tring to do is that when there is data in my contoller right after insert I am adding a JS to the page itself that will have my values bindedup with it.

bob_buzzardbob_buzzard

The way I'd handle this is to have the javascript in the page, but don't render it until the case is created.

 

Once you create the case, if you rerender the section with the javascript in it, the case information will then be available to that javascript.

 

There's an example of delayed rendering of javascript on my blog at:

 

http://bobbuzzard.blogspot.co.uk/2011/05/refreshing-record-detail-from-embedded.html

 

and an example of retrieving information from another object after the page load, and then using that in a rerender at:

 

http://bobbuzzard.blogspot.co.uk/2011/11/retrieve-related-object-fields.html

This was selected as the best answer