我有一个涉及几个不同框架/库的问题,尽管主要的是 Twitter Bootstrap(js) 和 Rails。
我的应用程序中有一个链接,它以一些 js 响应:
$(function() {
var $modal = $('<%= escape_javascript( render 'front_end/bookings/modal', :product => @product, :customer => @customer, :booking => @booking ) %>'),
$calendar = $modal.find('#calendar'),
currentProduct = <%= raw(@product.to_json) %>;,
initBookingCalendar;
$('body').append($modal);
$modal.modal('show');
/* Booking Calendar */
initBookingCalendar = function(el, productId) {
el.fullCalendar()
...
};
$($modal).on('shown', function() {
if($calendar.is(':empty')) {
initBookingCalendar($calendar, <%= @product.id %>);
}
});
});
问题是“显示”事件由于某种原因在 IE9 中没有触发!?我在这里重现了这个问题:http: //jsfiddle.net/tvkS6/并通过这样做使它工作:http: //jsfiddle.net/tvkS6/9/。问题是我不知道如何在我的代码中实现解决方案,因为我并不真正了解问题所在。
我必须等待 initBookingCalendar 直到模式完全显示的原因是 jQuery FullCalendar 插件要求元素在呈现日历之前可见。
任何提示表示赞赏!