Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Jquery jeditable, edit problem

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

792 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