IE7/8中jquery嵌套可排序列表的问题

发布于 2024-10-10 06:03:10 字数 3551 浏览 0 评论 0原文

我遇到了与此线程相同的问题

jQuery 意外的可排序行为

我的系统正在做同样的事情。我的代码和他的代码之间的唯一区别是我的代码是 100% 由 ajax 动态生成的,并且我将表插入到每个 LI 中,但遗憾的是结果是相同的。这是我为每个主列表条目插入的 html。

这是我的 html 中的空白列表,

<ul id=\"questionList\">

  </ul>

动态生成的

<li id="liName-11" class="ui-state-default">
  <table width="600" border=".5" cellspacing="2" cellpadding="2" class="singleBorder">   
    <tr>
      <td width="386" align="left" valign="top">
        <span id="quesEditText-11">Does Default Work
        </span>
        <table>
          <tr>
            <td>
              <span id="quesEditSpan-11" onclick="setEditField('ques', 11)">Edit
              </edit>
            </td>
            <td>
              <span id="quesUpdateSpan-11" onclick="updateQuestionCall('ques', 11)">Update
              </edit>
            </td>
            <td>
              <span id="deleteSpan-11" onclick="deleteQuestionAjax(11)">Delete
              </edit>
            </td>
          </tr>
        </table>
      </td>     
      <td width="200">
        <input type="text" id="answerBox11">
        <br>
        <a href="#" onclick="insertAnswer(11, 'answerBox11')">Insert Answer
        </a>
        <ul id="answerList-11">
          <li id="17">
            <span id="answEditText-17">lets try this answer
            </span>
            <table>
              <tr>
                <td>
                  <span id="answEditSpan-17" onclick="setEditField('answ', 17)">Edit
                  </edit>
                </td>
                <td>
                  <span id="answUpdateSpan-17" onclick="updateQuestionCall('answ', 17)" style="display:none;">Update
                  </edit>
                </td>
                <td>
                  <span id="deleteSpan-17" onclick="deleteAnswerAjax(17)">Delete
                  </edit>
                </td>
              </tr>
            </table>
          </li>
          <li id="13">
            <span id="answEditText-13">yet another question
            </span>
            <table>
              <tr>
                <td>
                  <span id="answEditSpan-13" onclick="setEditField('answ', 13)">Edit
                  </edit>
                </td>
                <td>
                  <span id="answUpdateSpan-13" onclick="updateQuestionCall('answ', 13)" style="display:none;">Update
                  </edit>
                </td>
                <td>
                  <span id="deleteSpan-13" onclick="deleteAnswerAjax(13)">Delete
                  </edit>
                </td>
              </tr>
            </table>
          </li>
        </ul>
      </td>   
    </tr> 
  </table>
</li>

这是由 javascript 和 ajax 调用根据上面线程中的建议

$("ul.list").live("mousedown", function(e){
        e.stopPropagation();
    });

,我将他的建议修改为这个,但它的效果为零。在 Chrome 和 Firefox 中完美运行,但在 IE 中却出现问题。相信我,我即将放入一个脚本,如果他们在 IE 中看到该网站,它会将他们转发到 Firefox 并告诉他们下载真正的浏览器,但我的老板不喜欢这个想法。你们有什么想法吗?

i am having the same problem as in this thread

jQuery unexpected sortable behaviour

my system is doing identically the same thing. the only difference between my code and his code is that my code is 100% generated by ajax on the fly, and im inserting tables into each of the LI, but alas the results are the same. here is the html im inserting for each of my master list entries.

here is the blank list thats in my html

<ul id=\"questionList\">

  </ul>

this is generated by javascript and ajax calls on the fly

<li id="liName-11" class="ui-state-default">
  <table width="600" border=".5" cellspacing="2" cellpadding="2" class="singleBorder">   
    <tr>
      <td width="386" align="left" valign="top">
        <span id="quesEditText-11">Does Default Work
        </span>
        <table>
          <tr>
            <td>
              <span id="quesEditSpan-11" onclick="setEditField('ques', 11)">Edit
              </edit>
            </td>
            <td>
              <span id="quesUpdateSpan-11" onclick="updateQuestionCall('ques', 11)">Update
              </edit>
            </td>
            <td>
              <span id="deleteSpan-11" onclick="deleteQuestionAjax(11)">Delete
              </edit>
            </td>
          </tr>
        </table>
      </td>     
      <td width="200">
        <input type="text" id="answerBox11">
        <br>
        <a href="#" onclick="insertAnswer(11, 'answerBox11')">Insert Answer
        </a>
        <ul id="answerList-11">
          <li id="17">
            <span id="answEditText-17">lets try this answer
            </span>
            <table>
              <tr>
                <td>
                  <span id="answEditSpan-17" onclick="setEditField('answ', 17)">Edit
                  </edit>
                </td>
                <td>
                  <span id="answUpdateSpan-17" onclick="updateQuestionCall('answ', 17)" style="display:none;">Update
                  </edit>
                </td>
                <td>
                  <span id="deleteSpan-17" onclick="deleteAnswerAjax(17)">Delete
                  </edit>
                </td>
              </tr>
            </table>
          </li>
          <li id="13">
            <span id="answEditText-13">yet another question
            </span>
            <table>
              <tr>
                <td>
                  <span id="answEditSpan-13" onclick="setEditField('answ', 13)">Edit
                  </edit>
                </td>
                <td>
                  <span id="answUpdateSpan-13" onclick="updateQuestionCall('answ', 13)" style="display:none;">Update
                  </edit>
                </td>
                <td>
                  <span id="deleteSpan-13" onclick="deleteAnswerAjax(13)">Delete
                  </edit>
                </td>
              </tr>
            </table>
          </li>
        </ul>
      </td>   
    </tr> 
  </table>
</li>

folling the suggestion in the above thread, ive modified his suggestion into this

$("ul.list").live("mousedown", function(e){
        e.stopPropagation();
    });

but it has zero effect. works perfectly in chrome and firefox, but screws up in IE. trust me im about to just put in a script where if they see the site in IE that it will forward them to firefox and tell them to download a real browser but my boss doesn't like that idea. you guys have any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

泪是无色的血 2024-10-17 06:03:10
  1. 确保您的 html 有效:您正在使用 关闭您的 元素
  2. 您的脚本适用于 ul 元素使用 list 类,您没有在 html 中的任何位置定义该类。
  1. Make sure your html is valid: you are closing your <span> elements with </edit>
  2. Your script applies to a ul element with a list class which you don't define anywhere in your html.
星星的轨迹 2024-10-17 06:03:10

http://api.jquery.com/event.stopPropagation/

你会注意到这一点live() 处理已传播到文档顶部的事件的页面,因此您需要使用 bind() 而不是 live()。

http://api.jquery.com/event.stopPropagation/

You'll notice on this page that live() handles an event after it's already propagated up to the top of the document, so you'll need to use bind() instead of live().

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