I have no amazing insight to offer onthis post, but hopefully it’ll make life easier for anyone looking in to the same issues that I just had with Prototype.
We’re making a dashboard where users are dynamically adding widgets, many of which need their own javascript functions to work properly. We really don’t want to have all those functions sitting around waiting for the widgets to be loaded, but when we loaded the code in to the page after the initial page load, none of the javascript came along, it was all stripped out.
Prototype has an that will allow the loaded page to contain Javascript code, but you also have to create your functions, like so:
coolFunc = function() { // Amazing stuff! }
That’s it, nothing too fancy, and nothing amazing; but hopefully this gets the word out there a bit more and makes it easier for someone else with this problem to find the answer.
sroub | 28-Jan-08 at 3:12 am | Permalink
How can you get data out of eval?
I “asked” the response from ajax with “evalScripts: true” and I set the javascript function in the “response” like you said
and???
what now??
sorry if I sound like an idiot
Christopher | 28-Jan-08 at 7:22 am | Permalink
@sroub - I’m not sure if I understand what you mean.
It’s been a long time since I’ve worked on this and I don’t do much javascript these days, so forgive me if I’m a bit rusty. With the above code, you should be able to access the function as coolFunc.
When I was working on this, most of the scripts were either Periodical Updaters or a quick flash of new content in another div; we just ran them to update the display, not to pass data around to other functions.
I’m probably not much help with this comment, but if you leave some further information I can try to point you in the right direction.
sroub | 29-Jan-08 at 1:58 am | Permalink
thanks for your quick response
I think I overcome my misunderstanding
have a nice day
sroub