CodeIgniter Forums
jquery + jeditable question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: jquery + jeditable question (/showthread.php?tid=12403)



jquery + jeditable question - El Forum - 10-17-2008

[eluser]Unknown[/eluser]
Hey all- I'm new to javascript and I'm trying to use jquery and jeditable.

Here is some code I'm using to make a tr element editable.

$("tr.journal-entry .actions a.edit").click(
function() {
$(".edit").hide();
$(".delete").hide();
$(this).parents("tr").find(".text").click();
return false;
}
);

The code is hiding the edit and delete links on all the entries on the page when this happens. That's exactly what I want. I can't make the links reappear though. Here's what I've currently got:

$('.journal-entry .text').editable(
'<?php echo Router::url("/folder/");?>update', {
id : 'data[entry][id]',
name: 'data[entry][text]',
type: 'textarea',
cancel: 'Cancel',
submit: 'Save',
tooltip: "Edit your journal entry",
onblur: 'ignore'
}

I tried changing the cancel parameter to have a function but it executes as soon as the box is made editable and that doesn't help me.

cancel: function(){
$(".edit").show();
$(".delete").show();
}

That didn't work like I'd hoped - the entry disappears, as do the links. I think because it executes cancel as soon as the button is made. Is there some way to add a function as a parameter that executes when cancel is pressed?


jquery + jeditable question - El Forum - 10-17-2008

[eluser]meigwilym[/eluser]
Coincidentally I just used Jeditable today, in a similar way. However I can't make out what you're trying to do so could you explain the intention first?

And BTW, this is CI discussion, not JS.

Reagrds,

Mei


jquery + jeditable question - El Forum - 10-17-2008

[eluser]Unknown[/eluser]
I've got a table set up like this:

date | editable entry | actions as links: delete, edit

When I click edit, all actions on all entries are hidden.

However, when I click "Cancel" or "save" I want the links/actions to reappear so that people may choose to edit or delete whatever they want, and can't figure out how to make that happen. Is that clear?

thanks!

oh, and sorry about the not being about CI. I'll try to find somewhere else..


jquery + jeditable question - El Forum - 10-17-2008

[eluser]meigwilym[/eluser]
I'm still not sure, but here goes.

Jeditable is to make the text itself clickable and editable. SO when you click on the text you want to change, the text changes to a text box, and it can be edited. When OK is clicked, the text is passed to a url, with a POST array.

This would mean that you don't need the edit link in your table, users can click straight on the text itself.

If you want to hide the cancel link, then this may work:
Code:
<!-- html -->
<tr class="journalentry">
  <td>date</td><td class="edit">Editable Text</td><td class="cancel"><a href="#">delete</a></td>
</tr>

&lt;!-- JS --&gt;
[removed]
$('.edit').click(function(){
  $(this).parent('tr.journalentry').children('td.cancel').hide();
});
[removed]

I'm not sure though. Try it and see. But I'm sure your original code ovecomplicates things.

Mei