How to handle file upload input change?

3,925 views
Skip to first unread message

Noel Abrahams

unread,
Nov 23, 2011, 3:00:47 PM11/23/11
to KnockoutJS
Hi,

I have an input element for displaying the file upload dialogue.

I've tried to bind it using Knockout JS 1.3 as follows:


<input class='file-upload' type="file" multiple="multiple"
accept="image/*" data-bind="change: function(e){alert('!!'); return
true;}" />

This does not work.

I am attempting to capture the "change" event, similar to the
following:

$('.file-upload').live('change', function () {

alert("!!");
});

Has anyone got this to work (without having written a custom binding)?

Thanks!

Koviko

unread,
Nov 23, 2011, 3:45:06 PM11/23/11
to knock...@googlegroups.com
As far as I know, there is no change binding. There is, however, an event binding.

<input type=file data-bind="event: { change: function(e){ alert('!!') } }" />

Noel Abrahams

unread,
Nov 23, 2011, 4:12:40 PM11/23/11
to KnockoutJS
Brilliant! thanks Koviko.
Reply all
Reply to author
Forward
0 new messages