gmac / backbone.epoxy

Declarative data binding and computed models for Backbone
http://epoxyjs.org
MIT License
615 stars 89 forks source link

Custom inputs or widgets for value binding #118

Open houpli opened 9 years ago

houpli commented 9 years ago

Hi,

I use custom inputs widgets like DatePicker or NumericTextBox (KendoUI). I would like to use "value" binding but I have to create my custom handler with addHandler.

Is it possible ?

Thank you

markerikson commented 9 years ago

Seems like that's exactly what custom handlers are intended for - creating binding interactions that aren't "standard". I've done exactly that myself with some jQuery plugins, like this one for jQuery-Knob:

        // Gets/sets the value for a $.knob() element
        knobValue : {
            set : function($element, value) {
                // Note that this does NOT appear to retrigger the knob's "change" handler, and
                // therefore we don't get into an infinite loop
                $element.val(value).trigger("change");
            },
            get: function( $element, value, event ) {
                return $element.val();
            }
        }