Events are inserted when the text is in the text field

events: { "paste .youtube-url" : "addUrl" }

addUrl: function(){
  console.log(this.$(".youtube-url").val());

So let's say I insert “bad” into the text box for the first time

console output : (empty line)

then if I insert add something like "coder"

console output : bad

instead of being inside the "badcoder" field, I assume that it is because the pesto paste event is fired before the text is inserted.

+5
source share
2 answers

Instead of using an event, pasteyou can use an event keyupthat fires if someone inserts, but also fires only after the input value has been updated.

UPDATE

@Micah ( @JohnnyO). , :

$('input').on('paste', function () {
    var that = this;
    setTimeout(function () {
        alert(that.value);
    }, 0);
});​

-, , , , . Chrome 21, -, , .

: http://jsfiddle.net/H4K4R/

+8

@Jasper . keyup. . , IE 9 "changechange", "enter". "propertychange" , , , Backbone, ".youtube-url".

+4

All Articles