Solved

Jquery jeditable, edit problem

Posted on 2011-02-12
2
569 Views
Last Modified: 2012-08-14
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
Comment
Question by:pixalax
2 Comments
 
LVL 4

Accepted Solution

by:
JayDiablo earned 500 total points
ID: 34879527
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
 
LVL 2

Author Closing Comment

by:pixalax
ID: 34883599
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now