如何给这个ID ?php美元行→名称;比;这样我就可以在AJAX中访问属性


How to give an ID to this <?php $row->name;?> so I can access the property in AJAX

我是代码点火器新手…我在每行前面都有一个编辑按钮。现在,我想要的是,在我点击编辑按钮后,应该出现一个弹出窗口/模型框/灯箱,而不需要页面刷新,并且所有字段都应该出现在该框中。

       <?php foreach($records as $row){?>
<tr>
<td class = "click"><?php echo $row->name; ?>  </td>

    <script type="text/javascript">
   $(document).ready(function() {
   $('.click').editable('<?php echo site_url('categoryController/editCategory');?>',
       {
     });
        });

包含元素的idname,如:

<tr>
<td class = "click" id="field" name="field_name"><?php echo $row->name; ?>  </td>
</tr>

然后在你的js:

$("#field").editable("<?php echo site_url('categoryController/editCategory'); ?>",
 { 
        indicator : "<img src='img/indicator.gif'>", // or any image
        onblur    : 'cancel',
        tooltip   : 'Click to edit...',
        cancel    : 'Cancel',
        submit    : 'OK'
}); 

然后在控制器中使用:

检索值
$this->input->post('field_name');
相关文章: