尝试构建一些模态窗口以在更好的界面中显示 crud。最好希望使用 Jquery 来执行此操作,因为打算在应用程序的其他部分使用 jquery-ui。
我的应用布局中有 div
<div id="modal-container"></div>
<div id="modal">
<a href="#" class="close">close</a>
</div>
然后被 Ajax 调用
$(function(){
var $modal = $('#modal'),
$modal_close = $modal.find('.close'),
$modal_container = $('#modal-container');
$('a[data-remote]').live('ajax:beforeSend', function(e, xhr, settings){
xhr.setRequestHeader('accept', '*/*;q=0.5, text/html, ' + settings.accepts.html);
});
$('a[data-remote]').live('ajax:success', function(xhr, data, status){
$modal
.html(data)
.prepend($modal_close)
.css('top', $(window).scrollTop() + 40)
.show();
$modal_container.show();
});
$('.close', '#modal').live('click', function(){
$modal_container.hide();
$modal.hide();
return false;
});
});
现在,还有一些样式等,但是,嗯……它看起来并不一流。我希望使用 lightbox 或 facebox 或其他一些看起来很酷的插件,但由于缺乏在线教程,到目前为止还不能使用。
有人可以帮助将这些实施到 Rails 3 中吗?
非常感谢!