5 ms·
That's the only javascript framework one needs. Actually I've been wanting to write something like that for a long time but didn't get around to it. Nice to se
by ishener 12y ago
That's the only javascript framework one needs.
Actually I've been wanting to write something like that for a long time but didn't get around to it. Nice to see someone else did exactly what I wanted...
- itry 12y agoDoes anybody have real world examples of websites that use this kind of thing? Im always under the assumption that the old "post data to server, save it there" model still works best. Am I missing something?
- sehr 12y agoTwo way binding doesn't necessarily negate that.
- ishi 12y agoOne possible use case is "live editing" of an object. Imagine a form that lets you build an HTML button from various properties: text, color, font, background, border-radius etc. Using way.js the button can be updated immediately whenever you change one of its properties, without waiting for a server response. And saving the data to localstorage is very useful when the user is spending a long time filling the form and then accidentally closes the browser / clicks BACK / etc. It's a bit like autosaving a draft version of the form.
- Lazare 12y agoIf what you're doing is simple enough that "serialise the form, send to server, wait for response, do a full page reload" works for you, then no, you don't need two-way data binding, and in fact wouldn't have any use for it. You only need two-way data binding if you need your client-side code to respond to user input, which a truly basic form doesn't need to do. Of course, for a good user experience, you probably want to do client-side validation of the form; while you can do that a bunch of ways one of the easier ways (from a developer's point of view) is two-way data binding, and I'm using it on a few contact forms, signup forms, file upload forms, etc., scattered around the web for just that purpose. And if you're doing something more complicated, then you probably want your client side code to respond to user input. If you're using ANY client-side MVC, or if you're getting real time updates from a server (via websockets or whatever), or if you're basically doing any sort of "app" style functionality in the client, you'll probably need two way data binding or its functional equivalent. I've written a big CRM webapp that uses two-way data binding extensively; the old "every click is a full HTTP round trip" model would deliver a shockingly bad user experience. That being said, two-way data binding isn't the only way to implement rich client-side functionality, it's just one of the conceptually simplest ways of doing it. Backbone has two-way data binding plugins, but the "default" is to use events instead. Ditto for React. But something needs to tie your client side code to user input, and one of the simple "somethings" is two way data binding. But again, if your app doesn't have any client side code, obviously you don't need anything to tie user input to the code you don't have. So if your app doesn't need any more client-side functionality than, eg, Hacker News has, then you have no need for two-way data binding (or, hell, any JS code at all). But if you want something a bit more interactive, then you need something. (That being said, I still have no idea what makes this library better than any of the many popular, mature libraries that already exist. I've used Knockout quite a bit; it works well.)
- itry 12y agoIm sceptical. You know why? You wrote all this text instead of giving me a real world example and said "look, this would be shitty without a 2-way-data-binding-library".
- 12y ago
- nailer 12y agoThe HTML5 formData looks exactly like this example. https://developer.mozilla.org/en-US/docs/Web/API/FormData https://developer.mozilla.org/en-US/docs/Web/API/FormData Weir thing is, the formData doesn't specify a working .toString(), so if you log it, it looks empty, and you can't see any of the values until you POST. Standards committees are wonderful.
- sanderjd 12y agoReading all your responses in this thread, it's clear that you want URLs to sites you can go look at rather than descriptions of times when this has been useful to individuals. You can find lots of examples of things built using data binding at the angularjs[0] and ember[1] showcase sites. A particularly well-known example of a nice application that relies heavily on data binding is discourse[2]. [0]: https://builtwith.angularjs.org/ https://builtwith.angularjs.org/ [1]: http://emberjs.com/ember-users/ http://emberjs.com/ember-users/ [2]: http://www.discourse.org/ http://www.discourse.org/ Some people prefer to do things your way, but lots of us really do like this sort of data binding and find it to be very useful.
- dabernathy89 12y agoHas Knockout not worked for you?
- Shorel 12y ago> That's the only javascript framework one needs. Tank: "It's a single celled protein combined with synthetic aminos, vitamins, and minerals. Everything the body needs."