0
我試圖用jQuery來實現一個portlet /小部件風格的界面,3列和拖放之間和之間。它的工作幾乎完全,除問題是爲什麼你正在使用jQuery(ui.helper[0])
代替jQuery(ui.helper)
它不會在IE6幫助與jquery ui.helper [0] = null在IE6
(function($) {
$.fn.portlet = function() {
return this.each(function() {
$(this).sortable({
connectWith: ['.portletColumn'],
handle: 'h3',
placeholder: 'drop',
forcePlaceholderSize: true,
start: StartDrag,
stop: StopDrag
});
});
};
function StartDrag(event, ui) {
try {
//in ui.helper[0] is null and hence the issue
//alert(ui.helper[0]);
currentlyDraggedNode = this;
alert(currentlyDraggedNode);
('.drop').css('height', jQuery(ui.helper[0]).outerHeight() + 'px');
$('.portletColumn').css('background-color', '#eee');
} catch (ex) { }
}
function StopDrag(event, ui) {
try {
$('.portletColumn').css('background-color', '#fff');
UpdateOrder();
} catch (ex) { }
}
function GetString(selector) {
var querystring = "";
$(selector).each(function() {
var id = $(this).attr('id');
if (id && id != '') {
querystring += id + ';'
}
});
return querystring;
}
function UpdateOrder() {
var querystring = GetString('#col1 .portletColumn .portlet') + '|;' + GetString('#col2 .portletColumn .portlet') + '|;' + GetString('#col3 .portletColumn .portlet');
$.get("/handlers/portlet.ashx?" + querystring);
}
})(jQuery);
如果不是某些瀏覽器會拋出javascript錯誤 – 2010-03-30 01:50:33