在 IE6 中帮助 jquery ui.helper[0] = null
我正在尝试使用 jquery 来实现 portlet/widget 样式的界面,有 3 列,并在它们内部和之间进行拖放。它几乎完全可以工作,除了在 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);
i'm trying to use jquery to implement a portlet/widget style interface, with 3 columns and drag and drop within and between them. it's working almost completely, except for issue that it doesn't work in 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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以问一下为什么你使用
jQuery(ui.helper[0])
而不是jQuery(ui.helper)
?我在 jQuery UI 源代码中看到的所有代码都以这种方式引用它
may I ask why you are using
jQuery(ui.helper[0])
instead ofjQuery(ui.helper)
?All the code I see in jQuery UI's source refers to it in that manner