Hi all, 

Hoping this is a simple fix, i have trawled the forums but cant find anything. 

I have a webblock with some javascript and some jquery in the form of an expression. The webblock is present within each row of a table on one of my pages. When the page loads initially, each row shows the webblock perfectly.

Whenever a change is made to a row, the cell is AJAX refreshed. It is at this point the webblock dissappears.

Any ideas? Much appreciated.


It was not clear your problem. Explain better.
Alright I'll try again!

Essentially the problem is I have a webblock which contains some JavaScript in the header, and some jquery inside an expression.
(It is the add calendar jquery plugin FYI )

Then on another webscreen i have a table records and each row of the table has an instance of the above webblock as well as other fields etc. 

When i make a change to the row I have to AJAX refresh the row/cell where the webblock is in. When i do that the webblock above disappears.  I think it is something to do with refreshing the jquery somehow?

Hope that's clearer!?


it's crazy ..
I've had several problems with jquery and javascript, but not specifically this.
It is hard to help you without knowing exactly how well this being done. I would not recommend updating the webblock that has the jquery. Put the plug in a webblock and would only make the functions in other webblocks
Have you already tried to put the Jquery code in a ready() event?
André, how would I do this? 


You just need to put your code inside the ready event, like this:

$( document ).ready(function() {
// Your code here

You can find more information here.

In Outsystems you can use the Ready action from SilkFramework (you will probally need to import its reference).

Hope it helps,
Hi Carlo,

After a ajax refresh all <script> tags inside the refreshed parts will look like they disappear,
but they will execute once anyway. Just like they would when the page is first rendered.
You just won't be able to see it in your browser debugger.

It's a side effect on how jquery works internaly, to avoid javascript from being executed multiple times by mistake when new html is added/changed in the page.

João Rosado
Brilliant thanks for the responses. Will give them a try and let you know.