jquery
  • ruby-on-rails
  • jquery-ui
  • 2011-11-14 32 views 0 likes 
    0

    我在Rails應用程序的ruby中使用jQuery模態對話框。這裏是我的代碼:JQuery模式對話框不能正確呈現

     var html = ''; 
         html += '<div id="dialog-form">'; 
         html += 'This is a test.'; 
         html += '<button id="form-close" class="close-button" type="button" onclick="$(\'#dialog-form\').dialog(\'close\');">Close</button>'; 
         html += '</div>'; 
    
         var dialog_form = $(html).dialog({ 
          autoOpen: false, 
          width: 600, 
          height: 640, 
          modal: true, 
          open: function() { 
           $(".ui-dialog-titlebar").hide(); 
          }, 
          close: function(event, ui) { 
           $('#dialog-form').remove(); 
          } 
         }); 
         dialog_form.dialog('open'); 
    

    我在另一個應用程序中使用了相同的代碼,並且它完美地工作。

    在我當前的應用程序中,不是渲染模態對話框,而是渲染透明的對話窗口。文本和按鈕呈現正確。但是,對話是透明的,而不是模態。

    我確定我已經包含了jquery.js和jquery-ui.js。

    我不知道我在做什麼錯。請幫忙。

    謝謝。

    +0

    聽起來像你還沒有將jquery-ui主題css文件添加到頁面中。 –

    +0

    謝謝,這就是我想念的。墨菲定律是例證! – rookieRailer

    回答

    0

    添加jquery css,js文件的引用。還要檢查對話框的類名是否正確。你需要在你的主div中添加更多的div(確切的代碼在jqueryui.com的jquery代碼的索引頁中)

    相關問題