請問為什么點取消后原來的內(nèi)容也不見了?怎么能夠保留?最后open的function為什么要引入event和UI兩個值?
?<script type="text/javascript">
??????????? $(function () {
??????????????? $("#btnDelete").bind("click", function () { //詢問按鈕事件
??????????????????? if ($("#spnName").html() != null) { //如果對象不為空
??????????????????????? sys_Confirm("您真的要刪除該條記錄嗎?");
??????????????????????? return false;
??????????????????? }
??????????????? });
??????????? });
??????????? function sys_Confirm(content) { //彈出詢問信息窗口
?????????????? $("#divtest").dialog({
??????????????????? height: 140,
??????????????????? modal: false,
??????????????????? title: '系統(tǒng)提示',
??????????????????? hide: 'slide',
??????????????????? buttons: {
??????????????????????? '確定': function () {
??????????????????????????? $("#spnName").remove();
??????????????????????????? $(this).dialog("close");
??????????????????????? },
??????????????????????? '取消': function () {
??????????????????????????? $(this).dialog("close");
?????????????????????? ?
??????????????????????? }
??????????????????? },
??????????????????? open: function (event, ui) {
??????????????????????? $(this).html("");
??????????????????????? $(this).append("<p>" + content + "</p>");
??????????????????? }
??????????????? });
??????????? }
??????? </script>
2016-04-26
回答你第二個問題,
最后open的function為什么要引入event和UI兩個值?
jQuery UI dialog 的參數(shù)說明文檔你可以去看看。
在本任務里:height、?modal、title、hide、都是初始化參數(shù),
而 open : dialogopen ? 是對話框事件。
? 當對話框打開后,觸發(fā)此事件,用法如下: ?
? 初始:$('.selector').dialog({ open: function(event, ui) { ... } }); ??
? 綁定:$('.selector').bind('dialogopen', function(event, ui) { ... });
其中兩個參數(shù),event表示事件對象,ui表示觸發(fā)此事件的控件。具體可以去網(wǎng)上查閱jQuery UI dialog插件的源碼,應該是里面定義的兩個變量。
2016-04-23
?$("#divtest").dialog({
??????????????????? height: 140,
??????????????????? modal: false,
??????????????????? title: '系統(tǒng)提示',
問題出在這里,第一,上面獲取ID那兒應該是$("#dialog-modal");
第二,modal:true。默認是true。
其他的我也不清楚,但是這兩個錯改過來是能夠正常運行的。