递归过多的问题

发布于 2024-09-15 15:22:29 字数 3070 浏览 4 评论 0原文

遇到递归问题。 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ま柒月 2024-09-22 15:22:29

找到了我的问题的解决方案。

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

改为:

<script type="text/javascript" src="js/jquery/jquery-ui-1.7.2.js"></script>

感谢那些提供帮助的人。

Found the solution to my problem.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

Changed it to:

<script type="text/javascript" src="js/jquery/jquery-ui-1.7.2.js"></script>

Thanks to those that assisted.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文