Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to clear validation messages
Message
From
12/04/2013 13:57:22
Mike Sue-Ping
Cambridge, Ontario, Canada
 
General information
Forum:
Javascript
Category:
JQuery
Miscellaneous
Thread ID:
01570813
Message ID:
01570827
Views:
35
This message has been marked as a message which has helped to the initial question of the thread.
Like I'd mentioned, it was a SWAG :) I was thinking that you could try destroying the dialog and recreate it when needed.

From elsewhere on the web:

$(this).dialog('destroy').remove()

This will destroy the dialog and then remove the div that was "hosting" the dialog completely from the DOM"



>If I try to remove the dialog by adding this code:
>
>
>var $dlg = $("#add-edit-dialog").dialog({
>   autoOpen: false,
>   show: "blind",
>   closeOnEscape: true,
>   resizable: true,
>   width: 1200,
>   height: 750,
>   minHeight: 600,
>   minWidth: 950,
>   buttons: {
>      Save: function () {
>
>         if ($("#add-edit-form").valid()) {
>
>            var urlLoc = '/Client/Edit/' + currentId;
>            if ($('#fntype').val() === "Add")
>               urlLoc = '/Client/Add';
>           
>            var form = $('form', this);
>            //debugger;
>            var oForm = form.serialize() + '&';
>            oForm = oForm.concat($('#frmClientsSearch').serialize());
>
>            $.ajax({
>               type: 'POST',
>               url: urlLoc,
>               data: oForm,
>               dataType: 'json',
>             
>               cache: false,
>               //contentType: 'application/json',
>               success: function (result) {
>                  
>                  $('#flexClients').flexAddData(result);
>               }
>            });
>            $(this).dialog('close');
>         } else return false;
>
>      },
>      Cancel: function () {
>        
>         //var validator = $("#add-edit-form").validate();
>         //   validator.resetForm();
>            
>         $(this).dialog("close").remove();
>      //   clearForm();
>      }
>   },
>
>   close: function () { $(this).remove() },
>   open: function () {
>   }
>});
>
>It never re-appears.
>
>
>>>Hi everybody,
>>>
>>>Right now I am observing the following behavior:
>>>
>>>1. I invoke my Edit form and make few validation errors to see validation messages
>>>
>>>2. I close the form without saving
>>>
>>>3. I open a new form and all validation messages are still here.
>>>
>>>I think my code is supposed to reset them - what do I miss?
>>>
>>>
>>>var validator = $("#add-edit-form").validate();
>>>
>>>var $dlg = $("#add-edit-dialog").dialog({
>>>   autoOpen: false,
>>>   show: "blind",
>>>   closeOnEscape: true,
>>>   resizable: true,
>>>   width: 1200,
>>>   height: 750,
>>>   minHeight: 600,
>>>   minWidth: 950,
>>>   buttons: {
>>>      Save: function () {
>>>
>>>         if ($("#add-edit-form").valid()) {
>>>
>>>            var urlLoc = '/Client/Edit/' + currentId;
>>>            if ($('#fntype').val() === "Add")
>>>               urlLoc = '/Client/Add';
>>>           
>>>            var form = $('form', this);
>>>            //debugger;
>>>            var oForm = form.serialize() + '&';
>>>            oForm = oForm.concat($('#frmClientsSearch').serialize());
>>>
>>>            $.ajax({
>>>               type: 'POST',
>>>               url: urlLoc,
>>>               data: oForm,
>>>               dataType: 'json',
>>>             
>>>               cache: false,
>>>               //contentType: 'application/json',
>>>               success: function (result) {
>>>                  
>>>                  $('#flexClients').flexAddData(result);
>>>               }
>>>            });
>>>            $(this).dialog('close');
>>>         } else return false;
>>>
>>>      },
>>>      Cancel: function () {
>>>         $(this).dialog("close");
>>>         clearForm();
>>>         if (validator)
>>>            validator.resetForm();
>>>      }
>>>   },
>>>   close: function () { clearForm(); },
>>>   open: function () {
>>>   }
>>>});
>>>
>>>Thanks a lot in advance.
>>
>>SWAG...how about destroying the dialog?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform