javascript - 使用 Jeditable 并在点击时激活

标签 javascript jquery jeditable

我找到了 this几乎正是我想要做的。我正在使用 Jeditable我可以使用默认设置。我还能够使上面论坛中的代码正常工作。我相信我的问题是,因为我使用的是表格,所以我需要做其他事情来选择前一个元素。

这是我的 HTML

   <table>
    <tr>
        <td width="5%"><input  class="cat_checkbox" type="checkbox" name='delete_cat[]' value='<?php echo("$cat_data[cat_id]");?>' /></td>
        <td width="90%" class="edit_cat_title" id='unique_id'>Category</td>
        <td width="5%"><a href="#" class="edit_cat_title_trigger"><img src="images/edit.gif" border="0"></a></td>
     </tr>
</table>

这是我的 JQuery:

 //modify title content on the fly  
    $('.edit_cat_title').editable('action.php', { 
         name : 'cat_title',  
         indicator : 'Saving...',
         submit    : 'OK',
         cancel    : 'Cancel',
         tooltip:'click to edit',
         event  : 'edit'
      });

//trigger with the click of the edit image
    $(".edit_cat_title_trigger").bind("click", function() {
    $(this).prev().trigger("edit_cat_title");
});

我知道我可能应该能够弄清楚,我知道我所要做的就是将 $(this).prev().trigger("edit_cat_title"); 更改到右边事情,但我对 Jquery 还是很陌生。

最佳答案

与其依赖 dom 结构来触发编辑事件,不如考虑在两者上设置一个 rel 标签,以便对它们进行更有限的分组。这将使您的代码与标记更加分离。那么选择器就是 $('.edit_cat_title').filter('[rel='+$(this).attr('rel')+']')

关于javascript - 使用 Jeditable 并在点击时激活,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1586825/

相关文章:

javascript - 如何将文件从 PhoneGap/webapp ftp 到服务器?

jquery - 验证可编辑字段

javascript - 如果在 animate() 之后设置 hide() jquery animate 函数,它不起作用?

javascript - Angular 1.4.5 : Uncaught Error: [$injector:modulerr] ngRoute

JavaScript 表格不显示

javascript - 动态背景图像不显示在引导模式上

javascript - 来自事件的 Jquery pageX 和 screenX 在第二台显示器上为负数

jquery - Chrome 中通过 jQuery 的新警告

jquery - jeditable vs editable in datatable - 有什么区别

php - jEditable 选择数据源