Welcome Guest, Not a member yet? Register   Sign In
jquery + jeditable question

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() {
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(){

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?

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.



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?


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

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:
<!-- html -->
<tr class="journalentry">
  <td>date</td><td class="edit">Editable Text</td><td class="cancel"><a href="#">delete</a></td>

&lt;!-- JS --&gt;

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


Theme © iAndrew 2016 - Forum software by © MyBB