remy / bind.js

bind.js - simple two way data binding to HTML and callbacks
694 stars 62 forks source link

Modifications over dom #26

Open Charly-T opened 8 years ago

Charly-T commented 8 years ago

I work with multiple forms, and i use to disable and hide a lot of fields. Would be nice to be able to access the dom via model, so the code could be much more cleaner.

My (maybe imposible) idea, is to access like myModel.firstField.el.prop('disabled', true) If 'el' returns the jQuery element of the dom linked to the field. Maybe $(myModel.firstField.el).prop('disabled, true) If jQuery is nasty inside the bind.js

By now, I've changed it to this.el = function (target) { if(typeof settings.mapping[target] === o) { return jQuery(settings.mapping[target].dom); } else { return jQuery(settings.mapping[target]); } }; What results in myModel.el('firstField').prop('disabled', true) But im not really happy with it... in fact, it hurts... Also, the __export function, returns 'el' as a property... but I cannot dig into the code that easy... If this is not useful for all, at least, how to do it right?