所以,像往常一样,我试图用JQuery在我的舒适区之外工作;我有一个表格,显示我的俱乐部网站上的内容创建者正在进行的任务的工作状态('未开始'正在进行'以及完成')
我想要的是让用户能够点击当前状态,并显示一个包含所有三个选项的下拉框(如在PHPMYAdmin ENUM字段中),并且用户可以选择新状态,并自动提交值。
这一切都正常,但问题是我似乎只能让JEditable发送一个静态值(select的内容)但是我需要它来发送select和an的内容作业的ID,以便系统知道要更新的作业以及将其更新为...
我有以下代码:
HTML
<table>
<tr><th>Page Title</th><th>Assigned To</th><th>Date Assigned</th><th>Job Status</th><th>Last Edited</th><th>Last Edited By</th></tr>
<tr><td><a href="/heroes-and-heroines-larp-world/nations/the-emerald-empire.html" target="_blank">The Emerald Empire</a></td><td> sebsmith</td><td>2014-07-16 00:00:00</td><td class="amber editable_select">In Progress</td><td>2014-07-19 11:05:46</td><td>sebsmith</td></tr>
<tr><td><a href="/heroes-and-heroines-live-roleplaying-links.php" target="_blank">Heroes and Heroines Live Action Roleplaying Club Links</a></td><td> sebsmith</td><td>2014-08-23 15:26:43</td><td class="red editable_select">Not Started</td><td>2014-08-23 15:55:56</td><td>sebsmith</td></tr>
<tr><td><a href="/heroes-and-heroines-live-roleplaying-links/larp-clubs/index.html" target="_blank">Heroes and Heroines Live Action Roleplaying Club - Links to other LARP Clubs and Systems</a></td><td> sebsmith</td><td>2014-08-23 15:35:56</td><td class="red editable_select">Not Started</td><td>2014-08-23 16:00:34</td><td>sebsmith</td></tr>
<tr><td><a href="/heroes-and-heroines-live-roleplaying-links/larp-suppliers/index.html" target="_blank">Heroes and Heroines Live Action Roleplaying Club - Links to suppliers of LARP equipment, costume and other essentials</a></td><td> sebsmith</td><td>2014-08-23 15:42:32</td><td class="red editable_select">Not Started</td><td>2014-08-23 16:01:04</td><td>sebsmith</td></tr>
<tr><td><a href="/heroes-and-heroines-live-roleplaying-links/larp-misc/index.html" target="_blank">Heroes and Heroines Live Action Roleplaying Club - Links to other Miscellaneous LARP Sites</a></td><td> sebsmith</td><td>2014-08-23 15:43:21</td><td class="red editable_select">Not Started</td><td>2014-08-23 16:01:22</td><td>sebsmith</td></tr>
<tr><td><a href="/heroes-and-heroines-live-roleplaying-links/larp-community/index.html" target="_blank">Heroes and Heroines Live Action Roleplaying Club - Links to LARP Communities</a></td><td> sebsmith</td><td>2014-08-23 15:44:23</td><td class="red editable_select">Not Started</td><td>2014-08-23 16:01:14</td><td>sebsmith</td></tr>
<tr><td><a href="/heroes-and-heroines-larp-world/nations/havdan.html" target="_blank">Havdan</a></td><td> sebsmith</td><td>2014-08-23 18:14:19</td><td class="red editable_select">Not Started</td><td>0000-00-00 00:00:00</td><td></td></tr>
<tr><td><a href="/heroes-and-heroines-larp-world/nations/enchantica.html" target="_blank">Enchantica</a></td><td> Fruitloop</td><td>2014-07-16 00:00:00</td><td class="amber editable_select">In Progress</td><td>2014-07-21 00:00:00</td><td>Fruitloop</td></tr>
<tr><td><a href="/heroes-and-heroines-larp-world/nations/the-fey-forest.html" target="_blank">The Fey Forest</a></td><td> Fruitloop</td><td>2014-08-23 18:06:11</td><td class="red editable_select">Not Started</td><td>0000-00-00 00:00:00</td><td></td></tr>
</table>
JS
<script src="/js/jeditable.mini.js"></script>
<script>$(function() {
$(".editable_select").editable("http://www.heroesandheroines.org/index.php?task=AJAXRequest&type=listContentJobsChangeJobStatus", {
indicator : '<img src="/assets/icons-set/indicator.gif">',
data : "{'Not Started':'Not Started','In Progress':'In Progress','Complete':'Complete'}",
type : "select",
submit : "OK",
style : "inherit",
});
});</script>
所以,我的问题是:&#34;如何让JEditable为“编辑选择”的每个单独实例发送一个ID? TD?有没有办法通过class属性发送id?或者通过js做一些聪明的方式?
我用JQuery慢慢地到达那里,但是有很多东西超出了我...... :(
谢谢!
的Seb
答案 0 :(得分:1)
你可以在你的td单元格中添加一个id。像这样:
<td id="job1status" class="amber editable_select">
Jeditable会自动将元素ID附加到帖子网址。所以,如果你在控制台(f12)中检查你的ajax帖子,你应该在最后看到它: ?的index.php任务= AJAXRequest&安培;类型= listContentJobsChangeJobStatus和ID = job1status