Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 593
  • Last Modified:

Jquery jeditable, edit problem

Hello all,
 I am using jquery tools + jeditable to edit instantly on the place.

 $(document).ready(function() {
     $('.note_edit').editable( site_url+'forms.php?do=edit_note', { 
	 indicator : '<img src="images/icons/loading10.gif">',
	name : 'note',
        cancel    : 'Cancel',
        submit    : 'OK'
     });
 });
</script>

Open in new window


div element
<div class="inner">
                        <div class="note_edit" id="<?php echo $info->id;?>"><?php echo (isset($info->note)) ? $info->note : "Click here to add some notes";?></div>
            		</div><!--ends .inner -->

Open in new window


Everything is smooth, I can edit (submitting the data works) but after submitting the data, it is writing "Click to edit". I have to reload the page to see the changes.

 Where am I doing wrong and where this "Click to edit" text is coming from? I will be glad if anyone could help me out with my problem.
0
pixalax
Asked:
pixalax
1 Solution
 
JayDiabloCommented:
Is the script you're posting to ("site_url+'forms.php?do=edit_note") returning the value that was entered?

Looking at the demos of jeditable, it appears that their server always returns the value that was entered.  Perhaps it populates the element with whatever is returned by the server, and if nothing is returned it defaults to "Click to edit"?

That's what this piece of code in the jeditable lib appears to be doing:

                                  success : function(result, status) {
                                      if (ajaxoptions.dataType == 'html') {
                                        $(self).html(result);
                                      }
                                      self.editing = false;
                                      callback.apply(self, [result, settings]);
                                      if (!$.trim($(self).html())) {
                                          $(self).html(settings.placeholder);
                                      }
                                  },

Open in new window


Specifically this block:

                                      if (!$.trim($(self).html())) {
                                          $(self).html(settings.placeholder);
                                      }

Open in new window


settings.placeholder defaults to "Click to edit".

/* Publicly accessible defaults. */
    $.fn.editable.defaults = {
        name       : 'value',
        id         : 'id',
        type       : 'text',
        width      : 'auto',
        height     : 'auto',
        event      : 'click.editable',
        onblur     : 'cancel',
        loadtype   : 'GET',
        loadtext   : 'Loading...',
        placeholder: 'Click to edit',
        loaddata   : {},
        submitdata : {},
        ajaxoptions: {}
    };

Open in new window

0
 
pixalaxAuthor Commented:
Sorry for the delay. I wrote it before going to sleep yesterday and Sunday I had a family day. Thank you for your help, I am a Jquery newbie, I didn't think of that.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now