Allow scripts in jQuery Mobile dialog box?

I have a page in jQuery Mobile, which is the main page. It has a list of items, and when you click on an item, it loads information about it. To dynamically load information, it calls an external page and brings everything. This external page has a small script to allow the user to process a button click (to send some information to the server).

When you load a page separately, it handles scripts very well. When you download it as a dialog, the scripts do not load.

I tried to put the script inside the page itself. I tried to place the script on the main page loading the dialog. None of this works. I debugged the console, and I cannot get it to read any scripts specific to the dialog of the external page.

Is there any trick, or are the dialogs just ignoring any scripts? Is there any way around this? Is there a way to completely stylize a page to look like a dialog until this problem is resolved?

Edit: I just did it without dialogue, and he still does it. If I load the page separately with AJAX turned off, everything will work. I need to save page transitions and the download dialog, so disabling it is not an option.

I am currently using an external page in my head:

<script> $(document).delegate("#productinfo", "pagecreate", function(){ //code here }); </script> 
+4
source share
2 answers

Posting an answer edited into a question:

I started by placing the script inside the page div:

 <div data-role="page" id="productinfo"> <!-- /markup--> </div> 

... and placing it at the very end after all.

As soon as I realized this, it worked several times, and not others. I couldn't figure it out until I realized that the z-index button was changed to 0, so it won’t take precedence over jQuery UI autocomplete whenever I select something for the field. I set z-index to 1 on the buttons (default 2, which overrides jQUI autocomplete to 1), and it seems to be working now.

I know that there wasn’t much activity, and probably it was a question that was asked before, but I couldn’t save anything on Google on my subject. Hope this helps someone in the future.

+1
source

I solved this problem by putting the js script on the main page:

 $(document).on("pageinit", "#my-dialog-page-id", function(e) { // put your js here }); 
+1
source

Source: https://habr.com/ru/post/1380964/


All Articles