开发者

jQuery UI modal input button value

I need to change the value of the input buttons created in the jQuery UI dialog modal to present them in the language of the user.

I don't see how to do it.

    var $dialog = $('<div><div style="padding:10px;text-align:left">'
        +'New name'
        +'</div>'
        +'<div style="padding:0 10px 10px 10px;text-align:left;">'
        +'<input id="dialogInput" style="width:370px" type="text"/>'
        +'</div></div>')
            .dialog({
        modal:      true,
        title:      'title',
        width:      400,
        buttons: {
            **'Ok'**: function() {
                $(this).dialog('close');
                return true;
开发者_如何学Python                },
            **'Cancel'**: function() {
                $(this).dialog('close');
                return true;
                }
            }
    }); 

Thanks!


Found a solution

    var $dialog = $('<div><div style="padding:10px;text-align:left">'
    +'New name'
    +'</div>'
    +'<div style="padding:0 10px 10px 10px;text-align:left;">'
    +'<input id="dialogInput" style="width:370px" type="text"/>'
    +'</div></div>')
        .dialog({
    modal:      true,
    title:      'title',
    width:      400,
    buttons: {
        **'Ok'**: function() {
            $(this).dialog('close');
            return true;
            },
        **'Cancel'**: function() {
            $(this).dialog('close');
            return true;
            }
        }
}); 

// i was missing the parent() traversing needed since the form is embedded in the dialog popup
$dialog.parent().find('button:contains("Ok")').text('New Ok text'); 
$dialog.parent().find('button:contains("Cancel")').text('New cancel text');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜