Created
November 28, 2011 12:38
-
-
Save moski/1400246 to your computer and use it in GitHub Desktop.
Make sure to disable the change event on the html input type file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
return $.extend($.fn, { | |
customBackboneLink: function(model) { | |
return $(this).find('input:not(:file)').each(function() { | |
var el, name; | |
el = $(this); | |
name = el.attr("name"); | |
model.bind("change:" + name, function() { | |
return el.val(model.get(name)); | |
}); | |
return $(this).bind("change", function() { | |
var attrs; | |
el = $(this); | |
attrs = {}; | |
attrs[el.attr("name")] = el.val(); | |
return model.set(attrs); | |
}); | |
}); | |
} | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment