Standard confirm dialog replacement

08 Apr '14, 01:26 PM
36,234 Views
No Forum Badges

How to manage the replacement of the standard confirm dialog using for example bootbox (http://bootboxjs.com/) or jquery.confirm (http://myclabs.github.io/jquery.confirm/) ?

I've tried including the correct js in the head section, modifying on-the-fly the jsp page link section onclick=" var c = bootbox.confirm('<c:out value="${_wr_message}"/>', .........." with no luck: the confirm dialog appears but the return value for c seems to be always true, so the navigation continues to the subsequent modal window even choosing "cancel".

Thanks

 
x 0
Follow
Answer Answer at this question and get points!
Forum Starter - Level 1

Hi Massimo,

 

for normal links we have two cases: anchor or button.

For an anchor the callback function has to replace the window href. In your jsp you should have something like:

onclick="bootbox.confirm('<c:out value="${_wr_message}"/>', 
  function(c) { if (c) { setWindowLocation('<webratio:Link link="ln1" position="index"/>'); }  } );
event.preventDefault ? event.preventDefault() : event.returnValue = false; 
return false;">

 

For a button you should submit the form, but you have also to specify the flow to follow. This can be done appending an hidden input to the form with the same name of the button.

In this case the jsp should be:

onclick="bootbox.confirm('<c:out value="${_wr_message}"/>', function(c) {

  if (c) { 
    $('#page1FormBean')[0].target='_self';
    $('<input type=hidden name=button:ln2 value=button></input>').appendTo($('#page1FormBean'));
    $('#page1FormBean')[0].submit();
}

} );
event.preventDefault ? event.preventDefault() : event.returnValue = false; 
return false;"

 

Emanuele

   
x 1
Forum Starter - Level 1

Hi Massimo,

using the native confirm dialog, the js is synchronous.

This is not possibile when you use other libraries. They are asynchronous rather than synchronous.

But all the libraries let you specify a callback function to execute after the user choice. In your case the onclick event in the jsp should be someting like:

onclick="bootbox.confirm('<c:out value="${_wr_message}"/>', 
  function(c) { 
    if (c) { ajaxRequest(.............); } 
  }
);
event.preventDefault ? event.preventDefault() : event.returnValue = false; 
return false;"

 

Emanuele

 
x 2
No Forum Badges

Thanks for the reply Emanuele. 
As soon as possible I'll test the suggested method.

Massimo

 
x 0
No Forum Badges

Hi Emanuele,

ok for the ajax links, it runs like clockwork, while I can not successfully convert the section of default.link.template concerning the normal links; I've tried as follows:

onclick="bootbox.confirm('<c:out value="${_wr_message}"/>', function(c) { if (c) {  $('#page1FormBean')[0].target='_self' } }); event.preventDefault ? event.preventDefault() : event.returnValue = false; return false;"

...confirm window appears, Cancel button closes the window while on Confirm after the window closes itself nothing happens (in this case the refresh of the page containing the link).

Probably the solution is simple but I can't get rid of this.

Thanks

Massimo

 
x 0
No Forum Badges

Hi Emanuele,

Perfect solution!
It would take me a month without your help.
Thanks a lot :-)


Massimo

P.S.: spammer in action in this post

 
x 0
No Forum Badges

I'm sorry but setWindowLocation(...) in script.js cannot manage the NewWindow parameter for the anchors, so I've created a new function based on the setWindowLocation function in the style custon.js that reach the goal:

function setNewWindowLocation(location) {

    if (jQuery.browser.msie) {
        if (!/^http:\/\/|^\//.test(location)) {
            var baseHref = jQuery("base").attr("href");
            if (baseHref) {
                if (baseHref.substr(baseHref.length - 1) !== "/") {
                    location = baseHref + "/" + location;
                } else {
                    location = baseHref + location;
                }
            }
        }
    }
    if (typeof wr == "undefined") {
        wr.LegacyAjaxPlugin.navigateLocation(location, "_blank");
    } else {
        window.open(location, "_blank");
    }
}

but I dont know if this approach is in respect of Webratio's standards

Is it the correct approach?

Thanks

Massimo

 
x 0
Answer at this question and get points!

Related questions

2 grids inside one/same cell result in non-selectable 2nd grid Access page variable in a page template add html Add logging capability to a Groovy script (unit) Add select all to Checkable List AJAX events problem to external JavaScript Ajax is not working in own style project Ajax web app with javascript history object using the WebRatio Alimentar graficas con base de datos Alternate way to get current User Oid in layout template groovy script? Any way to localize the Tab Grid Template (Webratio Store)? Applicare un template ad un Web Project Automatic file upload Ayuda Simple List Component Layout personalizado Bootstrap Style Button to go on another page Cambiare dimensioni bottoni - Change button size Can I inject html into custom unit template?! Change color template bootstrap style Change Style Changing the login page does not work ckeditor - change directory for the browser Colore Attributi index unit Dinamico - Index unit dynamic attribute color Como abrir una ventana en ajax desde una master page Como embeber un video subido desde archivo ? Como mostrar una imagen de portada arriba del menu? Como mostrar una imagen en una lista o en la componente detalles? Confirm Dialog Content module page variable won't assign. Convert selector component result to single value Criptare dati sensibili nel database Customize layout mobile platform Custom Tooltip Position Data flow from a page which is not visible anymore Default error pages default login page Display contents of a URL Dynamic link labelling for Custom Unit Error in Excel Unit - Font size Execute truncate sql query Export to a HTML/CSS/JS project Field as link soruce file analysis then update MySQL database File CSS non considerato in generazione Form element Form template Get date pattern Get home page from template Get size of Multi Form with Pictures Object Array Getting the absolute path of a RTXBLOBData Google map is not shown properly in the tab grid Groovy and Database Groovy script numer after an error Guardar Saltos de LINEA HelloWorld Unit sample code Hiding landmarks (or flows) when the user is logged in How can I add a credit card payment gateway or integrate paypal in my web app logic? How can i add html into a page? How can i create pagemenu or landmarkmenu with multiple levels. How can I modified the htmls files to perform my style how can i open a pdf file using download dialog How to add an image in a modal/pop-up window? How to calculate dates between start and end point? How to include a template into other template? How to localize AJAX waiting dialog? How to localize the multi message unit in the notification layout How to modify template? How to modify the FertileEnviroment Default page How to remove default Linked Resources? How to Retreive data from Multi Selection Field Array How to use LandmarkMenu as AJAX navigation how to use the landmark menu as AJAX navigation Importing JAR Libraries into Script Unit Importing jar library integrate framework to webratio mobile Integrazione javascript JAR importing Javascript and html javascript history object Localize "Welcome..." and "Process details" logo webratio meaning of each tag in the XML code (Show XML/Show Layout XML) Merge the result of 2 (or more) flows [MOBILE] Script doesn't work! modify field html Modify generated code / inject own HTML, Javascript code into existing generted code. Modify html generated by wr:NavigationBar Pages Problem After Project Generation pass template variable Problem Login Form only if user not logged Problem print Problems with the page refresh (Tab Grid) Problem with adding templates query unit who to hide fields that are used in a link Recursive Hierarchical Index Unit Style Tree Redirect to the default module Remove default BPM css import for all templates Responsive Bootstrap Grid Responsive Layout Manager script component Script eseguito alla User Login Script Unit e Mysql ScritpUnit and JSON data Set context parameter Setting Upload directory Shuffling Script Simple Static Page Style hierarchical unit help!! Supoort for Mobile and Desktop display Target tabs in Tab Grid Control Tooltip on a field Too much layout parameters = no scroll in parameters config window Unable to execute the script java.lang.NullPointerException upload file and the move it to other location Uppercase Use image as interaction flow Vista de diferentes Site Views WebRatio 6.1.2: Groovy Version / Versione Groovy Webratio Add-ons no permite login wr-ajaxDivs break layout on ajax pages.