1

simple question: How do I execute inline javascript in a HTML page snippet loaded with dojo.xhrGet()?
Being new to dojo I'm a bit confused this doesn't just work like in JQuery ...
Can anyone help??
Thanks,
thomas

1 Answer 1

1

We need more details! If you don't provide enough info you'll never get the right answer.

Anyway, if the HTML snippet is loaded inside a ContentPane, use a dojox.layout.ContentPane (is an extension to dijit.layout.ContentPane providing script execution).Or you could use one of the script tags that dojo accept. E.g:

<div dojoType=...>
 <script type="dojo/connect" event="functionToConnectTo">
    //javascript here
 </script>
</div>

More valuable information about script tags on dojo parser reference.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the answer! I had that problem in several situations but the problem right now is that I'm bulding an eternal scroller in symphony, that loads a component with a loop as soon as you get to the bottom of the page. Now only this component knows, what the maximum amount of pages is, but it's being loaded from several scripts with several parameters. Now I'm looking for a simple way to have this component tell the script the max amount of pages. Like <script>maxPages = 3;</script>in the components HTML ... I'll look into those dojo types ...
Sorry, but dojo has to be the worst documented Library ever. Please don't make fun of me, I just can't figure it out. Consider this: I want to load a HTML snippet via dojo.xhrGet() that contains this: <script>alert('Hello');</script>. How can this be executed???
Why would I make fun of you?! There is no shame in asking. The problem is that, runing a js function that is returned by ajax it's a tricky thing in jquery too. It doesn't have anything to do with Dojo. From what I know (and I may be wrong) with jquery, mootools, dojo and any other framework, the only way you could execute the js function is by using eval(the_js_function); Check the accepted solution of this question please: stackoverflow.com/questions/510779/…
Thanks Sica, that answer really helped! JQuery and prototype both have options to automatically execute inline js coming in via ajax so I have no experience in fishing out the scripts and eval'ing them. I'm positive I can figure it out now! Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.