为其附加元素后无法 jqeditable

发布于 2024-08-22 06:08:16 字数 1119 浏览 5 评论 0原文

我编写了一个脚本,为我的 SQL 数据库和网站创建一个新元素。 如果帖子是好的,我将返回帖子的 ID,这样我就可以像其他 DIV 一样制作 DIV 框。

问题是,我可以内联编辑所有 DIV 中的文本,但不能内联编辑创建的 DIV 中的文本。

ajaxRequest.onreadystatechange = function(){
    if(ajaxRequest.readyState == 4){
        var moveit = $("<img>").attr({src: "icons/arrow_switch.png", class: "handle", alt: "move"});
        var editarea = $("<div>Ide írjon szöveget</div>").attr({class: "edit_area", id: ajaxRequest.responseText});
        $("<li></li>").attr({id: "listItem_"+ajaxRequest.responseText}).append(moveit).append(editarea).appendTo('#test-list');
    }

原始 DIV 之一

<li id="listItem_84"><img alt="move" class="handle" src="icons/arrow_switch.png"><div id="84" class="edit_area">Ide írjon szöveget...</div></li>

示例: JS 创建的

<li id="listItem_88"><img src="icons/arrow_switch.png" class="handle" alt="move"><div class="edit_area" id="88">Ide írjon szöveget</div></li>

所以我真的不知道为什么我无法编辑新行?!请给我一个解决方案。

感谢您的帮助<3

I wrote a script, to make a new element to my SQL db and my website.
If the post is good, i will get back the ID of the post, so i can make a DIV box like the other DIVs.

The problem is, I can inline edit the texts in all of the DIVs but NOT in the created one.

ajaxRequest.onreadystatechange = function(){
    if(ajaxRequest.readyState == 4){
        var moveit = $("<img>").attr({src: "icons/arrow_switch.png", class: "handle", alt: "move"});
        var editarea = $("<div>Ide írjon szöveget</div>").attr({class: "edit_area", id: ajaxRequest.responseText});
        $("<li></li>").attr({id: "listItem_"+ajaxRequest.responseText}).append(moveit).append(editarea).appendTo('#test-list');
    }

Example: one of the original DIVs

<li id="listItem_84"><img alt="move" class="handle" src="icons/arrow_switch.png"><div id="84" class="edit_area">Ide írjon szöveget...</div></li>

the JS created DIV

<li id="listItem_88"><img src="icons/arrow_switch.png" class="handle" alt="move"><div class="edit_area" id="88">Ide írjon szöveget</div></li>

So i really don't know why i can't edit the new line?! Please give me a solution for this.

Thanks for your help <3

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

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

发布评论

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

评论(1

避讳 2024-08-29 06:08:16

您只在调用时所在的元素上调用了 editable ,但是您可以将其作为 ajax 函数的一部分装配到新元素上:

ajaxRequest.onreadystatechange = function(){
  if(ajaxRequest.readyState == 4){
    var moveit = $("<img>").attr({src: "icons/arrow_switch.png", class: "handle", alt: "move"});
    var editarea = $("<div>Ide írjon szöveget</div>")
                      .attr({class: "edit_area", id: ajaxRequest.responseText})
                      .editable(...same options here...);
    $("<li></li>").attr({id: "listItem_"+ajaxRequest.responseText})
      .append(moveit).append(editarea).appendTo('#test-list');
  }
}

只需为 .editable() 调用您在页面加载时使用的方法。

You only called editable on the elements that were there when the call was made, you can rig it up as part of your ajax function to the new elements though:

ajaxRequest.onreadystatechange = function(){
  if(ajaxRequest.readyState == 4){
    var moveit = $("<img>").attr({src: "icons/arrow_switch.png", class: "handle", alt: "move"});
    var editarea = $("<div>Ide írjon szöveget</div>")
                      .attr({class: "edit_area", id: ajaxRequest.responseText})
                      .editable(...same options here...);
    $("<li></li>").attr({id: "listItem_"+ajaxRequest.responseText})
      .append(moveit).append(editarea).appendTo('#test-list');
  }
}

Just put the same options in for the .editable() call as you used when the page loaded.

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