In case anyone is interested, I've got the normal "save" buttons (top-right of page) to work with a custom admin Vendor tab (with several fields):
$(document).ready(function () {
$("button[name = 'save']").click(function () { saveExtendedVendor(); });
$("button[name = 'save-continue']").click(function () { saveExtendedVendor(); });
});
function saveExtendedVendor() {
$.ajax({
cache: false,
type: 'POST',
url: '@Url.RouteUrl("ExtendedVendorSaveVendor")',
data: $("#vendor-extended-info *").serialize(),
dataType: 'json',
error: function (xhr, ajaxOptions, thrownError) { alert(xhr.responseText); }
});
return false;
}
However, the client side validation is not working (e.g. 'required field'). The validator is set up on the class:
[Validator(typeof(ExtendedVendorEditValidator))]
public class ExtendedVendorEditModel : BaseNopEntityModel
...
and, this is in the .cshtml file:
<div class="col-md-9">
@Html.NopEditorFor(model => model.Address1)
@Html.RequiredHint()
@Html.ValidationMessageFor(model => model.Address1)
</div>
And, when I inspect the HTML element in the browser, it has the ...class="field-validation-valid" data-valmsg-for=...
<div class="col-md-9">
<input class="form-control text-box single-line valid" data-val="true" data-val-required="Address Line 1 is required" id="Address1" name="Address1" type="text" value="10 MAIN St">
<span class="required">*</span>
<span class="field-validation-valid" data-valmsg-for="Address1" data-valmsg-replace="true"></span>
</div>
I use the same model (& validator) in a custom tab I put in the public vendor edit (in customer account) and it works fine. It just does not work in the admin vendor edit.
Thoughts anyone?