jquery为错误对话框设置了一个新的CSS类

jqgrid jquery set a new css class for a errors in dialog box

本文关键字:一个 CSS 错误 对话框 设置 jquery      更新时间:2023-09-26

对于检查服务器端验证错误,我使用jqGRid的"afterSubmit"属性。

afterSubmit: checkForErrors

我的checkForErrors是这样的

function checkForErrors(response,postdata){
    var success = true;
    var message = ""
    var json = eval('(' + response.responseText + ')');
    if(json.errors.length>0) {
        success = false;
        for(i=0; i < json.errors.length; i++) {
            message += json.errors[i] + '<br/>';
        }
    }
    var new_id = null;
    return [success,message,new_id];
}

我唯一需要修复的是改变jqgrid使用的默认错误类/样式。Ui-state-error)到我的自定义CSS类。我怎么能那样做呢?

谢谢!

试试这个:

function checkForErrors(response,postdata){
    var success = true;
    var message = ""
    var json = eval('(' + response.responseText + ')');
    if(json.errors.length>0) {
        success = false;
        for(i=0; i < json.errors.length; i++) {
            message += json.errors[i] + '<br/>';
        }
    }
    var new_id = null;
    //Here pass the right class name instead of ".dialog" which you are using in your code
   $(".dialog").find(".ui-state-error").removeClass("ui-state-error").addClass("newClass");
    return [success,message,new_id];
}