in Education by
I have some wizard-like pages in my application, its keeping state while navigating between small steps, the navigation is not linear and everything works well without one line of javascript in a "progressive enhancement" way. In my application, to users with javascript enabled, i want turn flow above in a set of dialogs by loading each complete step in a dialog by ajax, process the action of step and close dialog, each step will have the own script embedded to execute on dialog load and intercept some step ui events. The problem is that JQuery UI Dialog want create action buttons i cant give the button creation to plugin, its ask for buttons metadata and i already have complete functional page with form, buttons, data entry and everything i need to do my work, its working, its done, i Only want load it on a Dialog that manage window specific things to me, like Title bar, Drag by title bar, Close button on title bar, Close event to my cleanup, stretch to fit my dialog content, load in modal mode with overlay. I cant find a way to intercept the button click inside dialog by script embedded on dialog step, the button inside dialog must post data by ajax but it will post togheter the main page in a normal page posting. I found some very old plugins but i like JQuery UI, its simple and looks good, looking for something without iframe, i read about: boxy: http://onehackoranother.com/projects/jquery/boxy/tests.html simplemodal: http://www.ericmmartin.com/projects/simplemodal/ jqModal: http://dev.iceburg.net/jquery/jqModal/ @liho1eye : putting comments now Edit: With help of @liho1eye i reach it: //------------------------------------------------- var url_trg = '@Url.Content("~/Teste/opendialog")'; var url_prl = '@Url.Content("~/Images/waitplease.gif")'; //------------------------------------------------- function onloadpartial() { /*setupDialog("#opendialog", "#tempcontent", "section[id='main']", url_trg);*/ configDetailDialog(url_trg, "#tempcontent", "section[id='main']", "Detail", "#opendialog"); } //------------------------------------------------- function configDetailDialog(trgurl, containerselector, contentselector, dlgtitle, buttonselector) { //------- $(document).ajaxError( function (event, jqXHR, ajaxSettings, thrownError) { alert('[event:' + event + '], ' + '[jqXHR:' + jqXHR + '], ' + '[jqXHR_STATUS:' + jqXHR.status + '], ' + '[ajaxSettings:' + ajaxSettings + '], ' + '[thrownError:' + thrownError + '])'); }); //------- $.ajaxSetup({ cache: false }); //------- $(buttonselector).click(function (event) { event.preventDefault(); openAjaxDialog(trgurl, containerselector, contentselector, dlgtitle); }); //------- } //------------------------------------------------- function openAjaxDialog(trgurl, containerselector, contentselector, dlgtitle) { $.ajax({ type: 'GET', url: trgurl, context: document.body, success: function (data) { var dlg = $(data).find(contentselector); $('#dlgdetail').remove(); $(containerselector).append("
"); $('#dlgdetail').append(dlg); $('#dlgdetail') .css("border", "solid") .dialog({ autoOpen: true, modal: true, title: dlgtitle, open: function () { configDetailDialog(); }, close: function (event, ui) { $('#dlgdetail').remove(); } }) .find("form").submit(function (event) { alert('clicou ' + event); var form = $(this); var faction = "http://" + window.location.host + trgurl; var fdata = form.serialize() + "&action:savedialog=savedialog"; $.ajax({ type: "POST", url: faction, data: fdata, success: function (result) { alert(result); } }); event.preventDefault(); $('#dlgdetail').dialog('close'); }); } }); } //------------------------------------------------- ------------------------------------------------- JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I honestly think your dialog creation code is really overcomplicated with unnecessary DOM manipulation, which is immediately undone by dialog creation. Regardless... I read you question as "How do I rewrite AJAXed forms to submit via AJAX?". Well, simple. Add this function in the global scope var rewriteForms = function(); { $('#dlgdetail').find("form").submit(function() { var form = $(this); $('#dlgdetail').load(form.attr("action"), form.serializeArray(), rewriteForms); return false; }); } Then simply call after dialog was created rewriteForms(); This will take care of all forms (assuming they are submitted by and not via js code). If there are some buttons or links that do something custom, then you need to handle them to in the same manner as shown above.

Related questions

0 votes
    I'm trying to get a modal to pop up on cellClick. I'm not getting any errors, but it's not ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I'm using $.ajax() to load new pages on my site if certain conditions are met (a flash-based ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    I need to build a pop up dialog box in my app. I am using Dialog class and wrapped it with ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    I'm new to flutter and can't resolve the issue. Your application could not be compiled, because its ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I'm new to flutter and can't resolve the issue. Your application could not be compiled, because its ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    So I am trying to creating simple Login Page with help of the Spring Boot and Security. So what I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    Which of the following plugin in Bootstrap is used to create a modal window? popup alert modal window...
asked Mar 2, 2021 in Technology by JackTerrance
0 votes
    Which of the following plugin in Bootstrap is used to create a modal window? popup alert modal window...
asked Feb 28, 2021 in Technology by JackTerrance
0 votes
    3. The appearance of a web page can also be enhanced by adding______ in a web page Select the correct answer from above options...
asked Dec 2, 2021 in Education by JackTerrance
0 votes
    Could anybody give any piece of advice, or code, or documentation link where I can found: how to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 16, 2022 in Education by JackTerrance
0 votes
    2- What values must be inserted in Insert table dialog box to create a table ? Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    It is possible to autoplay a regular YouTube video in fancybox by appending ?autoplay=1 to the video URL: ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 8, 2022 in Education by JackTerrance
0 votes
    I've made a fresh eclipse reinstall + Android SDK v4.0. I am trying to create a new 4.0 AVD ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I got an openshift cluster with 2 nodes (a master and a slave), I want to change the config file ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    I am using simple thread to execute the httpGet to server when a button is clicked, but I get ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
...