javascript - jQuery UI Dialog - change the content of an open dialog (Ajax) -
I've got some links, I dynamically open in a jQuery UI dialog in jQuery.load () I want to use
. Once the dialog is open, I want the links to be loaded within the dialogue already opened.
- Then, the site loads, you click on a link, and it opens in a dialog. no problem. You can turn it off and open it as often as you want.
- Though it is open, if you click on a link with the loaded content, then it does not work.
- A GET request is made, but the resulting material is not loaded successfully in the dialogue. (Shows the request)
- The previous dialogue title and the dialog content has been erased but new content has not been shown, Nor is it inserted into the dome. (The source does not show the source anywhere.)
The links look like this ...
& lt ; A href = "http://www.example.com/index.php?action=something&search=somethingelse#fragment" rel = "dialog" title = "title attribute" & gt;
The click event is bound to ...
$ ('body'). Representative ("a [rel ~ = dialog]", "click", function (e) {back to ajax_dialog (this, e);});
ajax_dialog
to check the function checks whether there is a dialog, calls to make calls, calls to load content, sets title , And opens the dialog if it is not open.
function azax_admig (_this, _event) {var urLToLoad = $ (_ this) .attr ("href"). Replace ("#", "& Ajax = True #"); Var linkTitle = $ (_ this) .attr ("title"); // create dialog (! $ ('Body'). ('# AjaxDialog'). Size ()) {$ ('body'). Attachments ('init still in & lt; br / & gt;'); // This first click only shows init_dialog ('# ajaxDialog'); } // Load Dialog content load_dialog ('#jaxDialog', urlToLoad); // Add title $ ('# ajaxDialog'). Dialog ('option', 'title', linkital); // Open dialog (or reload) if (! $ ('# AjaxDialog') dialog ('isOpen')) {$ ('# ajaxDialog'). Dialog ('open'); $ ('Body') Attachment ('Not yet open & lt; br / & gt;'); // This first click shows only} Description is false; }
If no one then the init_dialog
function creates a dialog ...
function init_dialog (_this) {$ ( 'the body'). Attachment ('& lt; div id = "ajaxDialog"> ;); // set dialog option $ (_ this) .dialog ({modal: true, autoOpen: false, width: 900, height: 400, position: ['center', 'center'], xxxx: 99 99, // open : Function () {Load_dialog (this, urlToLoad);}, it did not work without destroying the dialog for every click. Close: function () {$ (this) .empty ();}}); }
load_dialog
function loads the desired content in the dialog.
As shown in the code, I $ jQuery.load ()
was using and the exact href
was dragging the link according to the request At the end of all the URLs were pieces / anchors, which is: .... html # id-of-div
.
In this case, the script is working fine But # id-of-div was not present on the page yet ... This is the reason I could see the content back, but the dialogue just ended.: -)
Comments
Post a Comment