سؤال

I am using dijit/Dialog module of dojo. Ajax popup is working fine but when I include any javascript in that popup that is not working please have a look on below code.

<script src="<?php echo $this->basePath()?>/js/dojo_lib/dojo/dojo.js" data-dojo-config="isDebug:1, async:1"></script>
<script>
    require(["dijit/Dialog"]);
</script>
<a title="Create a New Account" class="registration" href="javascript:void(0);" onclick="dijit.byId('user_registration').show();">Registration</a>
<div class="dijitHidden">
    <!-- dialog that gets its content via ajax, uses loading message -->
    <div data-dojo-type="dijit.Dialog" style="width:600px;" data-dojo-props="title:'Register',href:'/account/register',loadingMessage:'Loading form...'" id="user_registration"></div>
</div>

Above code is used to show popup.

popup page is something like this

<div>
Register
</div>
<script>
alert('Hello');
</script>

this alert is not working in that popup. Please help

هل كانت مفيدة؟

المحلول

tik27 has probably the best general answer (and it explains why it doesn't work out of the box).

If you don't want to do the evaluating by yourself, Dojo also has a module/widget called dojox/widget/DialogSimple (and dojox/widget/Dialog) and it has a property executeScripts. If you enable it, it will evaluate all scripts on that page.

So if you don't want to do the script evaluation yourself, try using this widget.

نصائح أخرى

Take a look at. Calling a JavaScript function returned from an Ajax response

It deals with javascript received from an ajax call, since this is what is happening in the background.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top