javascriptjqueryjeditable

Using Jeditable and activating on click


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.


Solution

  • 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