Iam*_*MAN 1 javascript jquery jquery-ui-dialog
我试图从Jquery对话框Ok按钮调用一个函数.
我试过这两种方法,
this.commentDialog = function(){
$("#commentDialog").dialog( "destroy" );
html = "<div id='cmtDialog'>";
html += "Comment<textarea id='comment'></textarea></div>";
$("#commentDialog").html(html);
$("#commentDialog").dialog({
title:"Search Result",
bgiframe: true,
height: 'auto',
width: 'auto',
modal: true,autoOpen: true,
buttons: { "Ok": function() { this.saveComment();}}
});
Run Code Online (Sandbox Code Playgroud)
this.commentDialog = function(){
$("#commentDialog").dialog( "destroy" );
html = "<div id='cmtDialog'>";
html += "Comment<textarea id='comment'></textarea></div>";
$("#commentDialog").html(html);
$("#commentDialog").dialog({
title:"Search Result",
bgiframe: true,
height: 'auto',
width: 'auto',
modal: true,autoOpen: true,
buttons: { "Ok": function() { saveComment();}}
});
Run Code Online (Sandbox Code Playgroud)
两个都不工作!
我该如何用jquery做到!!
谢谢!!!
this.commentDialog = function(){
// save a reference of "this" and use it later.
var me = this;
$("#commentDialog").dialog( "destroy" );
html = "<div id='cmtDialog'>";
html += "Comment<textarea id='comment'></textarea></div>";
$("#commentDialog").html(html);
$("#commentDialog").dialog({
title:"Search Result",
bgiframe: true,
height: 'auto',
width: 'auto',
modal: true,autoOpen: true,
buttons: { "Ok": function() {
// use me instead of this, as this now refers to the function.
me.saveComment();}}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16471 次 |
| 最近记录: |