vitalets / x-editable

In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
http://vitalets.github.io/x-editable
MIT License
6.51k stars 1.72k forks source link

Checklists #44

Closed tolmalev closed 11 years ago

tolmalev commented 11 years ago

Is it still possible not to display all selected values from checklist?

Like: "Selected 3 of 7"

It has been default behaviour yet, but doesn't work now.

tolmalev commented 11 years ago

Seems, that it was removed in this commit:

https://github.com/vitalets/x-editable/commit/8ed61d6b6b7d05f9ca8e325b3a8d04ad0a106643

vitalets commented 11 years ago

yes, it was replaced with display option that is more flexible. Now you can write:

editable({
    ....
    display: function(value, sourceData) {
        var limit = 5;
        if(value.length > limit) {
             $(this).html('checked '+value.length+ ' of '+sourceData.length);
        }
    }
});
tolmalev commented 11 years ago

May be you will make a default display function for checklist with such behaviour?

vitalets commented 11 years ago

in first version it caused additional options that looked for me as overload (limit, limitText.. ). But now I have an idea that display can be defined as string and serve as template ("checked X of Y"). btw, do you need limit option or you just need always show check-summary?

tolmalev commented 11 years ago

I don't know javascript. May be it is possible to do smth like this?

function defaultDiplay(limit) {
    return function(value, sourceData) {
       ...
    }
}

$("#name").editable({
 display: defaultDisplay(3)
})

Limit isn't necessary, but can be very useful.

vitalets commented 11 years ago

agree. limit seems usefull and I think to revert it in standard func. It's always ballance between convinience and number of options ) thx!