2011-05-15 56 views
0

好吧,別笑,但我的朋友給了我一個jQuery UI代碼的修復方法,然後再請求另一個修復方法,現在我不知道如何將這兩個方法結合起來。我總共是n00b,所以請在這裏幫助我。我嘗試過,但不斷收到語法錯誤?jQuery UI對話框代碼幫助

我需要合併這個(我認爲它會冠軍後右):

beforeClose: function(){ $(this).remove(); } 

進入這個:

function openDialog(url) { 
    $("<div class='popupDialog'>Loading...</div>") 
     .dialog({ 
      autoOpen: false, 
      closeOnEscape: true, 
      width: '900', 
      height: 'auto', 
      modal: true, 
      title: 'Bonus Features' 
     }).bind('dialogclose', function() { 
      jdialog.dialog('destroy'); 
     }).load(url, function() { 
      $(this).dialog("option", "position", ['center', 'center']).bind('dialogopen', function() { 
        adjustJQueryDialogOverlay(); 
       }); 
       $(this).dialog("open"); 
     }); 
} 

$(window).resize(function() { 
    $(".ui-dialog-content").dialog("option", "position", ['center', 'center']); 
}); 

任何人都可以請幫助?謝謝。

回答

1
function openDialog(url) { 
    $("<div class='popupDialog'>Loading...</div>") 
     .dialog({ 
      autoOpen: false, 
      closeOnEscape: true, 
      width: '900', 
      height: 'auto', 
      modal: true, 
      title: 'Bonus Features', //don't forget the comma 
      beforeClose: function(){ $(this).remove(); } //placed here 
     }).bind('dialogclose', function() { 
      jdialog.dialog('destroy'); 
     }).load(url, function() { 
      $(this).dialog("option", "position", ['center', 'center']).bind('dialogopen', function() { 
        adjustJQueryDialogOverlay(); 
       }); 
       $(this).dialog("open"); 
     }); 
} 

$(window).resize(function() { 
    $(".ui-dialog-content").dialog("option", "position", ['center', 'center']); 
}); 
+0

謝謝,謝謝,謝謝!嘿,你可能會建議一個好的網站,可以教我如何編寫代碼沒有語法錯誤? – DearRicky 2011-05-15 22:30:46

+0

這是一個開始使用jQuery的好地方:http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery在附註中,最後一個屬性不需要逗號(這就是爲什麼'title'沒有之前有一個逗號)。如果您使用的是jQueryUI中的某些內容,但不確定它爲什麼不起作用,請查看其網站上演示中的代碼:http://jqueryui.com/demos/希望有所幫助! – keyboardP 2011-05-15 22:33:46

+0

非常感謝。這肯定會有很大的幫助。但我還有一個問題要問你。我的朋友最近添加的修復程序是用於背景覆蓋。我有一個問題,如果對話框的高度超出了原來的網站背景,它會在中間切掉疊加層。他的修復解決了它。續... – DearRicky 2011-05-15 22:43:56