views:

434

answers:

2

Hi ,

i have some trouble to connect an link inside an dijit.dialog.

Iam calling an "other" html file inside the Dialog (dialog.href="xxx.html") inside this file iam trying to connect some links by id, to fire an alert box. But nothing happens ? Possible that this isnt possible ??

Thats the part from my xxx.html file..

<script type="text/javascript">
    dojo.addOnLoad(function( ) {
        dojo.connect(dojo.byId('testLink'), 'onClick', alert('xx'));
    }); </script>


<a href='#' id="testLink">TEST</a>
+1  A: 

Dialog is extended from ContentPane so it supports all the same parameters (href, etc.). With that said, when a page is included via the href property any <script> tags are not evaluated they are just added to the DOM. This leaves you with two choices:

  1. refactor xxx.html, so the script can be run by the dialog's onLoad handler
  2. embed the event handlers into the html tags; i.e. <input type="button" onClick="alert('xx');" />
Lawrence Barsanti
thanks for the idea to connect to the onLoad ! works fine!
ArneRie
+1  A: 

Another option would be to use dojox.layout.ContentPane. It'll parse <script> tags. It's in dojox though so it's liable to change in future version. And another downside is that this would require creating your own Dialog class that's a subclass of dojox.layout.ContentPane.

There's also an article on dojocampus about executing javascript in content panes which talks a little bit about using dojox.layout.ContentPane to roll your own Dialog widgets.

seth