Solved

Jquery jeditable, edit problem

Posted on 2011-02-12
2
565 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

706 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

19 Experts available now in Live!

Get 1:1 Help Now