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

thomas
  • 2,297
  • 2
  • 22
  • 23

1 Answers1

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.

sica07
  • 4,896
  • 8
  • 35
  • 54
  • 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 ``in the components HTML ... I'll look into those dojo types ... – thomas Aug 26 '11 at 07:54
  • 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: ``. How can this be executed??? – thomas Aug 30 '11 at 15:42
  • 1
    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: http://stackoverflow.com/questions/510779/calling-javascript-function-returned-from-ajax-response – sica07 Aug 30 '11 at 16:34
  • 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 – thomas Aug 30 '11 at 19:37
  • I'm glad that I could help you! Cheers – sica07 Aug 30 '11 at 19:43