How do i assign an an id to a jquery dialog button. I tried the following but it's not working
如何将id分配给jquery对话框按钮。我试过以下方法,但没有效果
buttons: {
Ok: function() {
id="xyz",
...
5 个解决方案
#1
64
The following (seemingly undocumented) works for me with jQuery 1.8.9:
以下(看起来没有文档)对jQuery 1.8.9适用:
$("#dlg").dialog({
buttons : {
"MyButton" : {
text: "My Button",
id: "my-button-id",
click: function(){
alert("here");
}
}
}
});
The button can be addressed via $("#my-button-id")
这个按钮可以通过$(“#my-button-id”)来解决。
#2
18
This code from official site worked for me:
来自官方网站的代码为我工作:
$('#dialog').dialog({
// properties ...
buttons: [{
id:"btn-accept",
text: "Accept",
click: function() {
$(this).dialog("close");
}
},
{
id:"btn-cancel",
text: "Cancel",
click: function() {
$(this).dialog("close");
}
}]
});
#3
3
@BerndB: Thanks it works perfectly and even is more extendable.
@BerndB:谢谢,它工作得很好,甚至可以扩展。
$('#loginlink').live('click',function(){
DC = 'login_box';
diaOpt = {
autoOpen : true,
width : 400,
title : 'Login',
buttons: {
//valiudate login
'Login' : {
text : 'Login Now',
id : 'validateForm',
click : function(){
}
}
}
}
launchDialog(diaOpt, DC);
});
$('#validateForm').live('click', function(){
alert('Hellop');
$("#loginform").validate();
});
#4
2
Try this.
试试这个。
buttons: {
'MyButton': function() {
//... configure the button's function
}
And the id setter
setter和id
$('button:contains(MyButton)').attr("id","xyz");
#5
0
$("#OK",{id:'xyz'});
hope that it helps
希望它能帮助
#1
64
The following (seemingly undocumented) works for me with jQuery 1.8.9:
以下(看起来没有文档)对jQuery 1.8.9适用:
$("#dlg").dialog({
buttons : {
"MyButton" : {
text: "My Button",
id: "my-button-id",
click: function(){
alert("here");
}
}
}
});
The button can be addressed via $("#my-button-id")
这个按钮可以通过$(“#my-button-id”)来解决。
#2
18
This code from official site worked for me:
来自官方网站的代码为我工作:
$('#dialog').dialog({
// properties ...
buttons: [{
id:"btn-accept",
text: "Accept",
click: function() {
$(this).dialog("close");
}
},
{
id:"btn-cancel",
text: "Cancel",
click: function() {
$(this).dialog("close");
}
}]
});
#3
3
@BerndB: Thanks it works perfectly and even is more extendable.
@BerndB:谢谢,它工作得很好,甚至可以扩展。
$('#loginlink').live('click',function(){
DC = 'login_box';
diaOpt = {
autoOpen : true,
width : 400,
title : 'Login',
buttons: {
//valiudate login
'Login' : {
text : 'Login Now',
id : 'validateForm',
click : function(){
}
}
}
}
launchDialog(diaOpt, DC);
});
$('#validateForm').live('click', function(){
alert('Hellop');
$("#loginform").validate();
});
#4
2
Try this.
试试这个。
buttons: {
'MyButton': function() {
//... configure the button's function
}
And the id setter
setter和id
$('button:contains(MyButton)').attr("id","xyz");
#5
0
$("#OK",{id:'xyz'});
hope that it helps
希望它能帮助