1

I found this to be almost exactly what I'm trying to do. I'm using Jeditable I can get the default setup to work. I've also been able to get the code in the forum above to work. I believe my problem is that because I'm using a table I need to so something else to select the previous element.

Here is my 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>

and here is my 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");
});

I know I probably should be able to figure it out and I know all i have to do is change $(this).prev().trigger("edit_cat_title"); to the right thing but I'm still really new to Jquery.

Community
  • 1
  • 1
Brooke.
  • 3,691
  • 13
  • 49
  • 80

2 Answers2

2

Rather than relying on the dom structure to trigger the edit event, you may consider setting a rel tag on both that groups them more finitely. This will decouple your code from your markup a bit more. Then the selector would just be $('.edit_cat_title').filter('[rel='+$(this).attr('rel')+']')

Alex Sexton
  • 10,401
  • 2
  • 29
  • 41
1

I figured it out, I just needed to get the pevious instance of .edit_cat_title I used this jquery for anyone wondering.

    $(".edit_cat_title_trigger").bind("click", function() {
    $(this).parent().prev('.edit_cat_title').trigger("edit");
});

Thanks

Brooke.
  • 3,691
  • 13
  • 49
  • 80