my status
I have a list of the objects (surveys) displayed on my home page If I click on the edit button for a particular item, then I have a modal pop up with the details of the items to edit. When the user clicks Save , I submit the form via AJAX. Whether on the basis of ModelState.IsValid == true, I want to update the model with valid information or update the list of items with new information and turn off the modal. In this way I am submitting this form: The only thing I can think of is to back the position of the modelstate with a flag from its controller. ISIIDID and this should partly show me 1) How will I do this? 2) Is there a better way? I found it: But it seems I'm going wrong about the whole thing. One way to quit using JSON is to see some elements within the returned HTML. If you are using any HTML assistants for Validation Messages ( In your case: My question
Update
HTML.ValidationSummary (), HTML.ValidationMessageFor () ), then they will present elements with specific classes that you decide on To see. If not, you can make your own standard. For example, if you are using
Html.ValidationSummary -method, then this class will provide a list with
validation-errors-errors . So you can define a variable like this and then handle the response.
var isValid = $ (response) .find (".validation-summary-errors"). Length == 0;
Success: function (result) is {var isValid = $ (results). Fund ("Verification-summary- Errors "). Length == 0; // If successful, reload the survey partial view (isValid) {$ ('#SearchBox'). Html (results); } // If validation again with the validation errors, the form again other {$ ('# editSurveyModal'). Html (results); }}
Comments
Post a Comment