递归过多的问题
遇到递归问题。 Firebug 说第 600 行:
// Recurse if we're merging object values
if (deep && copy && typeof copy === "object" && !copy.nodeType)
target[name] = jQuery.extend(deep,
// Never move original objects, clone them
src || (copy.length != null ? [] : {})
, copy); // <--- Line 600
这是来源:
$(function() {
var $gallery = $('#gallery'), $matcher = $('#matcher');
$('.rotatorImage', $gallery).draggable({ revert: 'invalid', helper: 'clone', appendTo: 'body', cursor: 'move' });
$('.rotatorImage', $galleryItems).draggable({ revert: 'invalid', helper: 'clone', appendTo: 'body', cursor: 'move' });
$matcher.droppable({
accept: '#gallery .rotatorImage, #galleryItems .rotatorImage', drop: function(ev, ui) {
copyProduct(ui.draggable, $matcher);
}
});
function copyProduct($item, section) {
if (section.children().length == 0) {
var cloneID = 'clone_' + $item.attr('id');
var existing = $('#' + cloneID);
if (existing.length == 0) {
// then allow it to be created
var clone = $item.clone();
clone.attr('id', cloneID);
clone.append('<div class="RemoveMatcherItem"><a href="javascript: RemoveItem(\'' + clone.attr('id') + '\');" class="greenlink">x</a></div>').appendTo(section);
SaveChanges();
}
}
else
alert('Only one product is allowed at a time for this section.');
}
});
function RemoveItem(cloneID) {
$('#' + cloneID).remove();
SaveChanges();
}
function SaveChanges() {
SaveMatches();
__doPostBack('<%=lnkSaveMatches.UniqueID%>', '')
}
function SaveMatches() {
var $rotImg = $('#matcher').find('.rotatorImage');
if ($rotImg.length > 0) {
$rotImg.each(function() {
var hdn = $('#<%=hdnMatcherID.ClientID%>');
hdn.val($(this).attr('productID'));
});
}
else
$('#<%=hdnMatcherID.ClientID%>').val('');
}
<asp:HiddenField ID="hdnMatcherID" runat="server" />
<asp:LinkButton ID="lnkSaveMatches" runat="server" OnClientClick="return SaveMatches();" OnClick="lnkSaveMatches_Click" Text="" />
<div id="matcher" class="matcher_" style="width: 120px; height: 120px; border: solid 1px; padding-left: 0px;">
<div class="rotatorImage ui-draggable" id='clone_pid_<%# Eval("ProductID") %>' productid='<%# Eval("ProductID") %>'>
<div style="height: 120px;">
<asp:Image ID="imgProduct" runat="server" Width="120" /><br />
</div>
<div class="RemoveMatcherItem"><a href="javascript: RemoveItem('clone_pid_<%# Eval("ProductID") %>');" class="greenlink">x</a></div>
</div>
</div>
protected void lnkSaveMatches_Click(object sender, EventArgs e) {
int matchID = hdnMatcherID.Value == "" ? 0 : Convert.ToInt32(hdnMatcherID.Value);
Suggestion.UpdateSuggestionItem(matchID);
}
关于我在哪里遇到递归问题的任何想法?
Running into a recursion issue. Firebug says line 600:
// Recurse if we're merging object values
if (deep && copy && typeof copy === "object" && !copy.nodeType)
target[name] = jQuery.extend(deep,
// Never move original objects, clone them
src || (copy.length != null ? [] : {})
, copy); // <--- Line 600
Here's source:
$(function() {
var $gallery = $('#gallery'), $matcher = $('#matcher');
$('.rotatorImage', $gallery).draggable({ revert: 'invalid', helper: 'clone', appendTo: 'body', cursor: 'move' });
$('.rotatorImage', $galleryItems).draggable({ revert: 'invalid', helper: 'clone', appendTo: 'body', cursor: 'move' });
$matcher.droppable({
accept: '#gallery .rotatorImage, #galleryItems .rotatorImage', drop: function(ev, ui) {
copyProduct(ui.draggable, $matcher);
}
});
function copyProduct($item, section) {
if (section.children().length == 0) {
var cloneID = 'clone_' + $item.attr('id');
var existing = $('#' + cloneID);
if (existing.length == 0) {
// then allow it to be created
var clone = $item.clone();
clone.attr('id', cloneID);
clone.append('<div class="RemoveMatcherItem"><a href="javascript: RemoveItem(\'' + clone.attr('id') + '\');" class="greenlink">x</a></div>').appendTo(section);
SaveChanges();
}
}
else
alert('Only one product is allowed at a time for this section.');
}
});
function RemoveItem(cloneID) {
$('#' + cloneID).remove();
SaveChanges();
}
function SaveChanges() {
SaveMatches();
__doPostBack('<%=lnkSaveMatches.UniqueID%>', '')
}
function SaveMatches() {
var $rotImg = $('#matcher').find('.rotatorImage');
if ($rotImg.length > 0) {
$rotImg.each(function() {
var hdn = $('#<%=hdnMatcherID.ClientID%>');
hdn.val($(this).attr('productID'));
});
}
else
$('#<%=hdnMatcherID.ClientID%>').val('');
}
<asp:HiddenField ID="hdnMatcherID" runat="server" />
<asp:LinkButton ID="lnkSaveMatches" runat="server" OnClientClick="return SaveMatches();" OnClick="lnkSaveMatches_Click" Text="" />
<div id="matcher" class="matcher_" style="width: 120px; height: 120px; border: solid 1px; padding-left: 0px;">
<div class="rotatorImage ui-draggable" id='clone_pid_<%# Eval("ProductID") %>' productid='<%# Eval("ProductID") %>'>
<div style="height: 120px;">
<asp:Image ID="imgProduct" runat="server" Width="120" /><br />
</div>
<div class="RemoveMatcherItem"><a href="javascript: RemoveItem('clone_pid_<%# Eval("ProductID") %>');" class="greenlink">x</a></div>
</div>
</div>
protected void lnkSaveMatches_Click(object sender, EventArgs e) {
int matchID = hdnMatcherID.Value == "" ? 0 : Convert.ToInt32(hdnMatcherID.Value);
Suggestion.UpdateSuggestionItem(matchID);
}
Any ideas on where I'm hitting my recursion issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了我的问题的解决方案。
改为:
感谢那些提供帮助的人。
Found the solution to my problem.
Changed it to:
Thanks to those that assisted.