views:

304

answers:

3

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.

Thanks

A: 

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

BandonRandon
A: 

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
Thanks Alex, I have to admit only half of that made sense. :)
BandonRandon
A: 

Thanks BandonRandon.. this works for me with Firefox 3.6.3 but not with IE8 I am using jQuery 1.4.2 with JEditable 1.7.1. I see an "Invalid Argument" error on IE8. I would appreciate your help :)

YogeshZ
Can you be more specific. Where do you see the Invalid Argument and what exactly are you trying to do? Possible start a new thread referencing this one.
BandonRandon