AnanthaKN / jquery-in-place-editor

Automatically exported from code.google.com/p/jquery-in-place-editor
Other
0 stars 0 forks source link

Pressing cancel button avoids a POST to the server, but the content of the editor is not restored #136

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Set show_buttons to true for a text field:

    $('.list_value').editInPlace({
        field_type: 'text',
        url: '/hey/its/a/url',
        show_buttons: true
    });

2. Click in a .list_value element (any text field instrumented with 
jquery.editinplace, and with show_buttons set to true).
3. Change the value of the text.
4. Click Cancel

What is the expected output? What do you see instead?

I expect the original text to be restored. If I refresh the page, I can confirm 
that the cancelled value was not posted to the server. But, the text I 
cancelled remains visible until I refresh.

What version of the product are you using? On what operating system?

Version 2.2.1. This is running on both OS X (dev) and Ubuntu Linux (staging). 
The environment is Rails 4.0.0, jQuery 2.0.3, jQuery UI 1.10.3, Chrome 30.

Please provide any additional information below.

I traced the problem to around line 385 of the source script. The problem is 
that the text field is not a selector, and this.isDisabledDefaultSelectChoice() 
returns false, so after this.restoreOriginalValue() is called at line 383, 
this.setClosedEditorContent(enteredText) is called 3 lines later. I fixed the 
problem by modifying isDisabledDefaultSelectChoice at line 425:

        isDisabledDefaultSelectChoice: function() {
                return this.settings.field_type != "select" || this.dom.find('option').eq(0).is(':selected:disabled');
        },

Original issue reported on code.google.com by jgvdth...@gmail.com on 30 Oct 2013 at 9:59

GoogleCodeExporter commented 8 years ago
Well, that doesn't entirely fix the problem. It seems to break the save as 
well. But that's the crux of the problem, at any rate.

Original comment by jgvdth...@gmail.com on 30 Oct 2013 at 10:10

GoogleCodeExporter commented 8 years ago
I also seem to be using version 2.3.0, according to the comments in the 
beginning of the file:

A jQuery edit in place plugin

Version 2.3.0

Apologies for the misinformation. I may try backing down to 2.2.1 to see if 
that fixes it too.

Original comment by jgvdth...@gmail.com on 30 Oct 2013 at 10:20