AnanthaKN / jquery-in-place-editor

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

replaceContentWithEditor rewrite #101

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
We found that the editor wasn't displaying, and although it was probably 
specific to our surrounding js, I was able to rewrite this method in a way that 
both worked, and shouldn't cause any problems elsewhere.
Personally, I think this is a better way to write it, removing the ".find"

    replaceContentWithEditor: function() {
        var buttons_html  = (this.settings.show_buttons) ? this.settings.save_button + ' ' + this.settings.cancel_button : '';
        var editorElement = this.createEditorElement(); // needs to happen before anything is replaced
        /* insert the new in place form after the element they click, then empty out the original element */
        var editor = $('<form class="inplace_form" style="display: inline; margin: 0; padding: 0;">')
                .append(editorElement)
                .append(buttons_html)
                .append('</form>');
        this.dom.html(editor);
    },

Original issue reported on code.google.com by iliketom...@gmail.com on 23 Aug 2011 at 7:35

GoogleCodeExporter commented 8 years ago
this code works in all browser except IE8 and IE7.. Please give me some 
solution.

Original comment by anupam82...@gmail.com on 17 Sep 2011 at 5:56

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Cause of this issue is in setInitialValue.
Fixed code is below.

    setInitialValue: function() {
        var initialValue = this.triggerDelegateCall('willOpenEditInPlace', this.originalValue);
        /* changed start */
        //var editor = this.dom.find(':input');
        var editor = this.dom.find(':input:not(:button)');
        /* changed end */
        editor.val(initialValue);

        // Workaround for select fields which don't contain the original value.
        // Somehow the browsers don't like to select the instructional choice (disabled) in that case
        if (editor.val() !== initialValue)
            editor.val(''); // selects instructional choice
    },

Original comment by manabe1...@gmail.com on 28 Feb 2012 at 2:53