Solved

Jquery jeditable, edit problem

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Trouble inserting a variable  in javascript 7 42
Show confirmation alert in Jquery 14 38
How can I   ajax html table  rows? 20 60
jQuery Syntax 2 47
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 Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

932 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

12 Experts available now in Live!

Get 1:1 Help Now