Giter Club home page Giter Club logo

jquery_jeditable's Introduction

jquery-jeditable

npm Codacy Badge GitHub license

DEPRECATION NOTICE

This project is deprecated and should not be used in a fresh project. Have a look at Malle library instead. It is more or less the same, but in typescript and without a jQuery dependency.

Alternative library

Use Malle.

Description

Edit in place plugin for jQuery (compatible with jQuery v3.4.0+).

Bind it to an element on the page, and when clicked the element will become a form that will be sent by asynchronous (ajax) POST request to an URL.

demo

Works with text inputs, textarea, select, datepicker, and more… Comes with a ton of different options you can use to do exactly what you want!

Live demo

See it in action: LIVE DEMO

Installation

npm install jquery-jeditable

Usage

Loading the library

Use a <script> tag loading the file dist/jquery.jeditable.min.js from your server, or use the CDNJS link.

Most basic usage

There is only one mandatory parameter. URL where browser sends edited content.

$(document).ready(function() {
     $('.edit').editable('save.php');
 });

Code above does several things:

Elements with class edit become editable. Editing starts with single mouse click. Form input element is text. Width and height of input element matches the original element. If user clicks outside form, changes are discarded. Same thing happens if user hits ESC. When user hits ENTER, browser submits text to save.php.

Not bad for oneliner, huh? Let's add some options.

Adding options

$(document).ready(function() {
    $('.edit').editable('save.php', {
        indicator : 'Saving…',
        event     : 'dbclick',
        cssclass  : 'custom-css',
        submit    : 'Save',
        tooltip   : 'Double click to edit…'
    });

    $('.edit_area').editable('save.php', {
        type      : 'textarea',
        cancel    : 'Cancel',
        submit    : 'OK',
        indicator : '<img src="img/spinner.svg" />',
        tooltip   : 'Click to edit…'
    });

    $('.edit_select').editable('save.php', {
        type           : 'select',
        indicator      : 'Saving ...',
        loadurl        : 'api/load.php',
        inputcssclass  : 'form-control',
        cssclass       : 'form'
    });
});

In the code above, the elements of class edit will become editable with a double click. It will show 'Saving…' when sending the data. The CSS class custom-css will be applied to the element. The button to submit will show the 'Save' text.

The elements of class edit_area will become editable with a textarea. An image will be displayed during the save.

The elements of class edit_select will become a selectable drop-down list.

Both elements will have a tooltip showing when mouse is hovering.

The live demo shows more example but with that you can already do plenty!

The complete list of options is available here: FULL LIST OF OPTIONS

What is sent to the server?

When the user clicks the submit button a POST request is sent to the target URL like this:

id=element_id&value=user_edited_content

Where element_id is the id of the element and user_edited_content is what the user entered in the input.

If you'd like to change the names of the parameters sent, you need to add two options:

$('.edit').editable('save.php', {
    id   : 'bookId',
    name : 'bookTitle'
});

And the code above will result in this being sent to the server:

bookId=element_id&bookTitle=user_edited_content

Loading data

If you need to load a different content than the one displayed (element is from a Wiki or is in Markdown or Textile and you need to load the source), you can do so with the loadurl option.

$('.edit_area').editable('save.php', {
    loadurl  : 'load.php',
    loadtype : 'POST',
    loadtext : 'Loading…',
    type    : 'textarea',
    submit  : 'OK'
});

By default it will do a GET request to loadurl, so if you want POST, add the loadtype option. And loadtext is to display something while the request is being made.

The PHP script load.php should return the source of the text (so markdown or wiki text but not html).

And save.php should return the html (because this is what is displayed to the user after submit).

Or you can pass the source in the data option (which accepts a string or a function).

I like writing sentences (and finishing them with text in parenthesis).

Using selects

You can use selects by giving type parameter value of select. Select is built from JSON encoded array. This array can be given using either data parameter or fetched from external URL given in loadurl parameter. Array keys are values for <option> tag. Array values are text shown in pulldown.

JSON encoded array looks like this:

{"E":"Letter E","F":"Letter F","G":"Letter G", "selected":"F"}

Note the last entry. It is special. With value of selected in array you can tell Jeditable which option should be selected by default. Lets make two simple examples. First we pass values for pulldown in data parameter:

$('.editable-select').editable('save.php', {
    data   : '{"E":"Letter E","F":"Letter F","G":"Letter G", "selected":"F"}',
    type   : 'select',
    submit : 'OK'
});

What if you need to generate values for pulldown dynamically? Then you can fetch values from external URL. Let's assume we have the following PHP script:

 <?php // json.php
 $array['E'] =  'Letter E';
 $array['F'] =  'Letter F';
 $array['G'] =  'Letter G';
 $array['selected'] =  'F';
 echo json_encode($array);

Then instead of data parameter we use loadurl:

$('.editable-select').editable('save.php', {
    loadurl : 'json.php',
    type   : 'select',
    submit : 'OK'
});

Styling elements

You can style input element with cssclass and style parameters. First one assumes to be the name of a class defined in your CSS. Second one can be any valid style declaration as string. Check the following examples:

$('.editable').editable('save.php', {
    cssclass : 'someclass'
});

$('.editable').editable('save.php', {
    loadurl : 'json.php',
    type    : 'select',
    submit  : 'OK',
    style   : 'display: inline'
});

Both parameters can have special value of inherit. Setting class to inherit will make the form inherit the parent's class. Setting style to inherit will make form to have same style attribute as its parent.

Following example will make the word oranges editable with a pulldown menu. This pulldown inherits style from <span>. Thus it will be displayed inline.

I love eating <span class="editable" style="display: inline">oranges</span>.
$('.editable').editable('save.php', {
    loadurl : 'json.php',
    type    : 'select',
    submit  : 'OK',
    style   : 'inherit'
});

Submitting to function instead of URL

Some people want to control absolutely everything. I want to keep you happy. You can get full control of Ajax request. Just submit to function instead of URL. Parameters passed are same as with callback.

$('.editable').editable(function(value, settings) {
    console.log(this);
    console.log(value);
    console.log(settings);
    return(value);
}, {
    type    : 'textarea',
    submit  : 'OK',
});

Note that the function must return a string. Usually the edited content. This will be displayed on the page after editing.

Other options

The demo contains other examples, have a look!

The complete list of options is available here: FULL LIST OF OPTIONS

Support

Please open a GitHub issue if you have a bug to report, a question to ask or if you just want to discuss something related to the project.

jquery_jeditable's People

Contributors

binarylogic avatar bonkowski avatar darwin avatar eman1986 avatar flavour avatar francesco-pesenti avatar hitsvilleusa avatar iedutu avatar jackdanger avatar jamoca avatar javierpdev avatar lawrencepit avatar mendizalea avatar michal-juranyi avatar nathanvda avatar nicolascarpi avatar robdet avatar spikex avatar thezoggy avatar tuupola avatar uplink03 avatar warmsocks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery_jeditable's Issues

Event propagation seems buggy on nested .editable elements

Hi, I have the following html structure, with nested div.wrapper element on which are binded dbbclick event to trigger jeditable:

<article>
    <section class="annotation1" data-section="1" id="section_data-section1" typeof="aa:section">
        <div class="wrapper" title="Doubleclick to edit...">
            <h1>Section </h1>
            <p>some content</p>
            <section class="annotation2" data-section="2" id="subsection_data-section2" typeof="aa:section">
                <div class="wrapper" title="Doubleclick to edit...">
                    <h2>Subsection </h2>
                    <p>some more content</p>
                </div>
            </section>
        </div>
    </section>
</article>

The problem is the event propagation seems incorrect and when I double-click a nested section it triggers .editable on the top-most parent. (see http://stackoverflow.com/questions/7429583/jeditable-propagation).

I tried to debug it by re-writing my javascript code like this:

$(document).ready(function() {
     $('div.wrapper').editable('edit/', { 
         loadurl   : 'edit/',
         //id        : 'section',
         name      : 'content',
         submitdata  : function(value, settings) {
             var section = $(this).parent('section').attr("data-section");
             return {
                 section: section,
                 type: 'ajax',
             }
         },
         loaddata  : function(value, settings) {
             var section = $(this).parent('section').attr("data-section");
             return {
                 section: section,
                 type: 'ajax',
             }
         },
         rows      : 6,
         width     : '100%',
         type      : 'textarea',
         cancel    : 'Cancel',
         submit    : 'OK',
         indicator : 'Saving changes',
         tooltip   : "Doubleclick to edit...",
         onblur    : 'ignore',
         event     : "edit",
         style     : 'inherit',
         callback : function(value, settings) {
             // console.log(this);
             //console.log(value);
             //console.log(settings);
             $('section[class^="annotation"]').each(function(index) {
                $(this).attr('data-section', index + 1);
             });
         }
     }).live('dblclick', function(e) {
         e.stopPropagation();
         console.log("srcElement: ", e.srcElement);
         console.log("target: ", e.target);
         console.log("currentTarget: ", e.currentTarget);
         console.log($(e.currentTarget).parent('section'));
         var target;
         $(e.currentTarget).trigger('edit');
     });
 });

It logs $(e.currentTarget) correctly (it shows the right div.wrapper) but for some reason $(e.currentTarget).trigger('edit') still triggers .editable on the top most parent div.wrapper (or rather it gets wrong after I dblclick a parent div.wrapper element, cancel, and then dblclick a nested element.

Any idea?

Thanks

HTML placeholder source presented for editing for empty elements

If I use HTML in the 'placeholder' option it is not detected correctly when editing an element and the HTML placeholder source is presented for editing for empty elements.

I have modified the following code to fix the problem for myself (tested on WebKit and Gecko):

    if ($(this).html().toLowerCase().replace(/(;|"|\/)/g, '') == 
                settings.placeholder.toLowerCase().replace(/(;|"|\/)/g, '')) {
                    $(this).html('');
            }

The only change was to add "|/" to the replace-regexp.

Create git tags for individual releases

Hi Mika,

it would be helpful to add tags for the different releases so that one can check the differences between a specific release and the current version in git. Right now i'm trying to track down why onblur doesn't fire and I would like to compare the git version with the 1.7.2 release version. Having tags would help me here.

You can add the tags afterwards like this

git tag tagname commit

Then sync them with

git push --tags

Thanks
Frank

Suppressing form submission

Apologies if this is fixed in the current version, I'm having real trouble figuring out where the latest code is.

When I upgraded to jquery 1.7.1 the forms started submitting and the page would reload, causing the ajax request to fail. I had to add return false here:

                            var submit = $(settings.submit).click(function() {
                                if (submit.attr("type") != "submit") {
                                    form.submit();
                                    return false;
                                }
                            });

And that then caused a preventDefault() in jquery.

The form submitted twice when redefining the submit element

Hi everybody,

Today, I found a small problem with the jeditable widget.

When I redefined the submit parameter, with a button (without a type attribute), the form is submitted twice.

In fact, if we do not specify a type attribute to a button, its default value is "submit". But, in the jeditable script, we test if the type is null, and if it is the case, we add a new handler to the button, which will submit the form.

if (settings.submit.match(/>$/)) {
                        var submit = $(settings.submit).click(function() {
                            if (submit.attr("type") != "submit") {
                                form.submit();
                            }
                        });
                    /* Otherwise use button with given string as text. */
   }

Do you already find a solution to this problem ?

Thanks a lot.

Emmanuel

unbinding via destroy does not work correctly

jeditable should use namespaced events (http://docs.jquery.com/Namespaced_Events) to bind the specified event. Otherwise calling editable('destroy') will unbind all other events bound to the selector.

Example:
$('div').click(function() {
alert('Hanlder 1 running');
});

$('div').editable('http://www.example.com/save.php');

Now calling $('div').editable('destroy') will unbind both the first handler and the handler bound via editable.

Solution:
Let jeditable bind a namespaced event. Add the following code somewhere to the initialization part of jeditables code:
settings.event += '.editable';

patch: catch loadurl ajax error

i've added "loaderror" as a callback function in the jEditable options.

if the "loadurl" page returns an error (eg. permission denied 403 or page not found 404) then this will get called.

i've emailed the patch to tuupola at appelsiini dot net

loadurl fix (for slow response)

$.ajax({
type : settings.loadtype,
url : settings.loadurl,
data : loaddata,
async : true,
success: function(result) {
window.clearTimeout(t);
input_content = result;
input.disabled = false;

   content.apply(form, [input_content, settings, self]);  

}
});

if (!settings.loadurl) {
content.apply(form, [input_content, settings, self]);

}

A somewhat different usage scenario: sending a complete form instead

Hi,

assuming an object with a number of editable properties: if the user clicks into any of those, a inplace editor appears. If the user is done, however, instead of posting his/her change to the server an "OK/Revert" button pair appears, and only after the user clicks "OK" the entire object - not only the changed property - is sent to the server.

This would probably need rewiring in a number of places in the plugin; but maybe someone did this already?

Getting message "Disallowed Key Characters"

When trying to edit content, it returns an "Disallowed Key Characters" message

$('#list li:not(.checked) span').editable(CI.base + 'lists/update_item', {
    id:         function(){ var item_id = $(this).parent().attr('id').split('_'); return item_id[1]; },
    indicator:  'Saving',
    tooltip:    'Double click to edit',
    event:      'dblclick',
    submit:     'Save',
    submitdata: {action: 'update'}
});

Does anyone know what's wrong?

Edit mode got lost without preserving changes

I've found an issue with the editable fields when navigating to another browser tab or application while editing.

Scenario:

  1. Goto Jeditable demo page http://www.appelsiini.net/projects/jeditable/default.html
  2. Edit Normal Textarea
  3. Change it's value (without clicking ok or cancel)
  4. Change to another browser tab or application
  5. Go back to browser tab with Jeditable demo page

Now the editable Normal Textarea is not in edit mode anymore and the changes are lost. While when I left the page the field was in edit mode.

I found out this happens in IE, FF and Chrome. Only Safari seems to remember the field was in in edit mode.

Use case is that end-users are changing the field in edit mode and want to open another browser tab or application to copy paste some text.

do input.focus(), not only $(input).focus()

I really should construct a test case for you for this one, but I'll have to get back to that.

The symptom I'm seeing is that when I

  1. put a tabindex on a jeditable span (with $().live, using the approach you suggested in issue #18)
  2. I tab to the element, and it opens as editable
  3. keyboard input doesn't go in to the input element
  4. pushing tab moves on without triggering the blur handler

This is because the input element never actually received focus. There's a line that does $(':input:visible:enabled:first', form).focus(); , and that does fire, but according to
http://www.w3.org/TR/wai-aria-practices/#focus_tabindex :

Use element.focus() to set focus - Do not use createEvent(), initEvent() and dispatchEvent() to send focus to an element, because these functions do not change the focus. DOM focus events are informational only, generated by the user agent after an element has acquired focus, but not used themselves to set focus.

this is perhaps a bug/feature request for jQuery, but in the meantime, I think it would help for jeditable to do the element.focus explicitly.

cancel and blur bindings not useful on hidden input

I'm working with a custom input type, and like the timepicker demo, I have my element function returning a hidden input. But that means that the various keycode and blur bindings bound to input returned by "element" are not useful. Can these be bound to the form instead, or provide some other hook?

Chrome sorts select elements by id not text

This is a chrome-specific bug but there should be a workaround withing Jeditable code. When creating select data, Chrome will sort the resulting select element by the option ids not option text.

Jeditable submitting to function not working in chrome/safari

I created a basic example that highlights the issue: http://bl.ocks.org/1462746

Basically, in chrome/safari, the content temporarily changes, but returns back to the original after a short delay. This does not happen in firefox. I attempted to debug it, and nothing stood out to me as to why it was changing back (only did so once within the jquery code). Any help would be much appreciated.

select fields don't take current value as selected for me

This code didn't work for me on Firefox.

                /* Loop option again to set selected. IE needed this... */
                $('select', this).children().each(function() {
                    if ($(this).val() == json['selected'] ||
                        $(this).text() == $.trim(original.revert)) {
                            $(this).attr('selected', 'selected');
                    }
                });

The following, hopefully simpler and faster did:

        if(json['selected'] == undefined)
        {
            json['selected'] = $.trim(original.revert);
        }
                /* Loop option again to set selected. IE needed this... */ 
                $('select', this).children().each(function() {
                    if ($(this).val() == json['selected'] ) {
                            $(this).attr('selected', 'selected');
                    }
                });

Submitting a form with multiple fields

Instead of submitting each individual field's change, I'd like to submit a form at the end (when the user clicks Save, after editing multiple fields).

My purpose for using jeditable is mainly aesthetic. I want fields to have click-to-edit capability, but not to immediately POST the change once a single field is edited.

How can I accomplish having a Save button at the end of a bunch of textboxes (each of which have .editable() applied). So I can then use AJAX to post this form when Save is pressed. I couldn't find a single example of this. BTW, beautiful plugin :)

EDIT: Even if this is not exactly possible, I basically just want to prevent any immediate POST, so I can collect the fields and POST it myself when the user presses Save.

Add support for onEditCallback function

It is currently not possible to extend the edition mechanism (for example to modify other elements of the page when editing: hide the images, put the rest of the page in grey...)

It is simple to add an onEditCallback parameter called just after that the edit form is displayed (based on the callback model):

  • @param Function options[onEditCallback] Function to run before editing the content **
    [...]
    var onEditCallback = settings.onEditCallback || function() { };
    [...]
    onEditCallback.apply(self, [self.innerHTML, settings]);

Tabbing from input to submit button fails

Given the following the following conditions are met:

  • you are using "submit", "cancel" or a function for onblur option
  • you have defined "submit" and/or "cancel" buttons

When you navigate with the TAB key from the input element to either of the buttons, the input element is blurred and the "onblur" option is triggered although from the user's point of view the focus is not lost from the editable input.

So if you want to navigate to OK button using a tab key', you lose any changes you have made.

I think the onblur should be triggered only after the focus is in none of the controls: the input, the submit button or the cancel button.

Cache select element

The display of the inline editing select could be sped up if the element would be cached after its first creation (given that no function was supplied to fill in the data, ie it contains only static data). When the input editor is canceled/submitted the select is simply hidden and not removed from the DOM tree.

file input type causes error

hey is this a bug? I have input type="file" on my page (unrelated to my use of jeditable). but on page load, I get this error. when i remove that input the error goes away.

"$.editable.types[settings.type] is undefined"

onBlur function should support a return value to allow for normal cancellation

I've noticed that if I define an onBlur function, it will run that function but leave the form intact without "cancelling".

It would be nice if we were able to return "true" to maintain this "halt the cancellation" behaviour, but return false to keep the standard behavior (if no onBlur is defined)

This way, people can keep track of both "on cancel" and "on submit" events.

Need ability to define target function in terms of click target

I like to avoid hard-coding URLs in my JS. To that end, I tend to put them as data-attributes on my elements. This way I can have my templating technology (e.g. django template language or haml) appropriately resolve the URL and attach it to the element in this way. This also helps keep my JS static and not also templates (a choice that we could debate, but that's the choice I've made).

So, using that practice with jquery_jeditable, I would want to have a data attribute for the target. Currently, if the target argument is a function it receives the edit-value and settings object. This leaves me without the target element to read attributes off of this.

I can currently work around it by calling editable on each element individually, e.g., by setting each up in a $(".editable").each(function(e) {}) block, but this is not quite ideal. It would be nice if the target resolution support built-in were more robust, and the target function could receive the original elements to read data attributes off of.

Since I have a workaround, this isn't urgent. I wouldn't mind submitting the pull request if I can set aside some time in the intermediate future, but that won't be right now.

request: add onEdit event

I would like to request an "onEdit" event.

This would make it easier for people to detect when an edit event has begun, allowing them to fully customise the text prior to editing.

This will help solve your "please strip markup", newline or formatting issues and allow for some more customisation to jEditable.

It should be a small tweak to the code block which checks if it is an Ajax load.

a) stores the original element html() somewhere
b) retrieves the ajax content from "loadurl"
c) puts it into the element for editing

altered:
a) stores the original element html() somewhere
b) passes the original html to "onEdit" handler
c) retrieve the output and store the same way the ajax content is saved
d) puts it into the element for editing

Add hook into select creation

It'd be nice to have a way to override/modify the creation of the select element with a hook that receives the element after it's been created (assuming it's stored somewhere once and not created dynamically every time).

For example, if you want to add a custom option at the end of a select that triggers an event.

ajaxfileupload is obsolete

Hi there,
Thank you for the great plugin! Unfortunately ajaxfileupload (since jquery 1.5) is unusable since it used undocumented jquery functions which are not supported any more.
I was wondering, would it be possible to make your plugin compatible with popular ajaxForm plugin (http://jquery.malsup.com/form/).

Alex

Transmitted Value

I noticed that the key-value assignement in the option "data" with "type:select" always send to the webserver the content of the select instead of the key.

I patched it by modifying this line :

var option = $('').val(key).append(json[key]);

by this one

var option = $('').val(key).attr('value', key).append(json[key]);

Hope it can help.

Text Input

This is more of a suggestion than an issue, but the default input when passing 'text' does not have a 'type' property on it, see:
text: {
element : function(settings, original) {
var input = $('');

My suggestion is to alter this to:
text: {
element : function(settings, original) {
var input = $('');

My reasoning is:

  1. I don't think the tag is valid without the "type" attribute
  2. (and actually more important to me) Having the type makes the field easier to custom style plus it will then automatically inherit all of my "input[type='text']" styles that already exist.

clearTimeout(t) - t is undefined

In this block:

                var t;
                if ('cancel' == settings.onblur) {
                    input.blur(function(e) {
                        /* prevent canceling if submit was clicked */
                        t = setTimeout(function() {
                            reset.apply(form, [settings, self]);
                        }, 500);
                    });
                    alert(t);
                } else if ('submit' == settings.onblur) {
                    input.blur(function(e) {
                        /* prevent double submit if submit was clicked */
                        t = setTimeout(function() {
                            form.submit();
                        }, 200);
                    });
                } else if ($.isFunction(settings.onblur)) {
                    input.blur(function(e) {
                        settings.onblur.apply(self, [input.val(), settings]);
                    });
                } else {
                    input.blur(function(e) {
                        /* TODO: maybe something here */
                    });
                }

t is not getting set inside the event functions.

Therefore:

                    if (t) {
                        clearTimeout(t);
                    }

is not clearing the setTimeouts.

To reproduce this, set the onblur to cancel, then alert out t in the form.submit function.

Using jeditable with custom function returns undefined

Hi tuupola,

I need to use a custom function to save my input from the jEditable element, as I need to show a dialog (jQuery UI's) to propmt the user that he/she made the correct edit before saving it.

Unfortunately it seems that jEditable doesn't wait for the AJAX call and instead of the returned value from the AJAX call, returns undefined which shows on the page while the AJAX call continues in the background.

Any ideas?

Here's the code:


$('#quickEdit').editable(quickEditable, { 
    loadurl:   url.quickEditable
});

function quickEditable(value, settings) {

    var defaultValue = this.revert;

    // Check that the value is changed.
    if (defaultValue == value) {
        return defaultValue;
    }

    $("#dialog").dialog({
        buttons: {
            "OK": function() {
                $(this).dialog("close");
                return $.ajax({
                    type: "POST",
                    url: url.quickEdit
                    async: false,
                    data : {/* Some data */}
                }).responseText;
        },
            "Abort": function() {
                $(this).dialog("close");
                     return defaultValue;
                }
        }
    });   
}

self.editing out of sync

I'm looking at a case where I'm using jeditable with datatables, and if the datatable row gets updated when I'm editing something in that row, the input form goes away but the "editing" attribute on the node is left set to true. Then next time I click on the cell to edit it, it hits the "if (self.editing)" case, and skips out.

So self.editing should be unset at some point where it isn't. I'm not quite sure where the right place to add that hook is. At the moment I'm binding to "DOMNodeRemoved" on the editable form node.

jEditable Custom Form submit

I am using jeditable to edit form and stuck at custom form submit to server.

There is product description box I need to edit. when some click edit it pops-up a window with product description in editable mode with a extra drop-down box (asking for reason what is user changing). However, I need only description to display on webpage but not reason.

How can I do this?

Example code


$.editable.addInputType('autogrow', {
 element : function(settings, original) {
 var hourselect = $('');
 var textarea = $('<textarea id="text" />');
 $(hourselect).append(
 $('').text('Select a reason').val(''),
    $('').text('Adding new Description').val('1'),
    $('').text('Editing Grammar').val('2')
  );
 $(this).append(hourselect);

 if (settings.rows) {
  textarea.attr('rows', settings.rows);
  } else {
  textarea.height(settings.height);
  }
  if (settings.cols) {
   textarea.attr('cols', settings.cols);
  } else {
  textarea.width(settings.width);
  }
    $(this).append(textarea);
    /* Last create an hidden input. This is returned to plugin. It will */
    /* later hold the actual value which will be submitted to server.   */
   var hidden = $('');
    $(this).append(hidden);

    return(hidden);
},
plugin : function(settings, original) {
    $('textarea', this).autogrow(settings.autogrow);
},
submit: function (settings, original) {
var value = $('#text').val();
    $('input', this).val(value);
 }
});


I can only send one value to server i.e. text or reason using hidden input field. However, I want to send reason and update description to server.

Has anybody came across this problem or use-case and provide some guidance?

I was using timepicker as my example.

Viral

Custom html tags in submit cause failure

If i include custom html tags in the submit attribute then the jeditable never returns back to a normal div. the form remains. see below

$('.editable').editable( function(value, settings) {
//console.log(settings);
return(value);
}, {
type : 'textarea',
tooltip : 'Click to edit...',
onblur : 'ignore',
height : '50px',
//submit : "ok1", // this works
submit : "
ok1", // this doesnt.
cancel : "",
});

Add class to editable item

It would be nice to add a classname (perhaps as a param) to the item that becomes editable. I'm adding this to individual elements using #id selectors, and would rather have editable add a class name to these so I can style them with css (or even addition javascript pizazz). I thought that's what the cssclass param does, but that doesn't seem to be the case.

Edit Button

Hello, Thank you for an excellent plugin. It works superbly, and is extremely easy to use.
I have a feature suggestion, maybe you can add an option that would add an icon or text next to the editable field, and once this icon/text is clicked the edit form activates.
Tooltip helps in guiding users what to do, but a more visual aid could be very handy.
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.