This is a migrated thread and some comments may be shown as answers.

Form submit binding

3 Answers 451 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Qaiser
Top achievements
Rank 1
Qaiser asked on 16 Sep 2012, 08:31 PM

Hi, 

Is it possible to data-bind a form submit? I know how to bind on button click but I would like to know if I can bind for form submit e.g <form data-bind='submit: handleSubmit'></form>.

Regards, 

3 Answers, 1 is accepted

Sort by
0
Rick Beerendonk
Top achievements
Rank 1
answered on 23 Jan 2013, 12:11 PM
Me too!
0
Atanas Korchev
Telerik team
answered on 23 Jan 2013, 02:00 PM
Hello,

 You can subscribe to any event via the events binding:

<form data-bind='events: { submit: handleSubmit }'></form>.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Rick Beerendonk
Top achievements
Rank 1
answered on 23 Jan 2013, 02:51 PM
That is a lot simpler than a custom binding:

    kendo.data.binders.submit = kendo.data.Binder.extend({
        init: function (element, bindings, options) {
            //call the base constructor
            kendo.data.Binder.fn.init.call(this, element, bindings, options);
 
            var self = this;
            //listen for the submit event of the element
            $(self.element).on("submit"function () {
                return self.submit(); //call the submit function
            });
        },
        refresh: function () {
        },
        submit: function () {
            this.bindings["submit"].get();
            return false;
        }
    });
Tags
General Discussions
Asked by
Qaiser
Top achievements
Rank 1
Answers by
Rick Beerendonk
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or