5 ms·
Try knockout. I wrote a quick intro to it a few days ago: http://returnbooleantrue.blogspot.com/2012/12/architecting-knockoutjs-applications.html http://return
by jtchang 14y ago
Try knockout. I wrote a quick intro to it a few days ago:
http://returnbooleantrue.blogspot.com/2012/12/architecting-knockoutjs-applications.html http://returnbooleantrue.blogspot.com/2012/12/architecting-k...
I personally don't like backbone that much. I don't know why so many people love the damn thing. It is hard to understand and not even that great.
- johnnymonster 14y agoI personally use knockout all the time. Can't stand backbone or angular after using knockout.
- hnwh 14y agoBackbone I understand, but why not angular? It seems quite similar to knockout to me? Whats your backend platform?
- CapnCrooked 14y agoI just finished evaluating frameworks for a project and chose Knockout over angular for a couple of reasons: Extensibility & hooks: Extending built in behavior in Knockout was much easier than in Angular. Without getting into too much detail, one of the things I tried to do was create a list of items on the page with a simple animation for item removal. In Knockout, it was trivial. In angular it would have required a copy-pasta style rewrite of the repeat directive. Some weird missing features: Angular has no conditional add/remove element directive (that I could find). This just seems like a weird oversight. There's a show/hide element directive, but trying to substitute that for add/remove will break CSS first/last/nth child selectors. Angular has a lot of potential, but it felt to me like it needs a few more iterations before I'd want to try to build a rich UI on top of it.
- ganarajpr 14y agoYou are right about the first situation. Currently doing animations with Angular is not a trivial task. This is mostly because of its "No DOM manipulation in Controllers clause". If you break that clause, having a repeat with animations is possible ( not trivial - but possible! ). Angular does have a conditional add/remove element. You can use ng-switch for that. If you are using CSS selectors in an angular app I sense a smell. Something is not right.
- CapnCrooked 14y agoYeah, I came up with a number of potential workarounds to the animation issue, all of which involved doing "non-angular" things. That wasn't ideal, but what really turned me off was how difficult it seemed to be to extend, compose, wrap, or otherwise re-use directives. You're right - you could use ng-switch for add/remove. It's a bit awkward though. I'm curious as to why you'd consider "CSS selectors" a smell in an angular app. I'm assuming you mean some subset of CSS selectors (possibly just the first/last/nth-child selectors I mentioned?), as without selectors you can't really have CSS.
- ganarajpr 14y agoOh sorry, I was under the assumption that you were using CSS selectors in JS not in CSS.. If its in CSS, then it should be fine. If you are using CSS selectors in JS in an angular app.. then that seems like a smell.
- thibaut_barrere 14y agoI have the same question as @hnwh: I'm using Knockout and really, really like it (more suited to my way of working than say Backbone), but considered that Angular could be a more advanced/featureful Knockout. Can you elaborate a bit? Thanks!
- jtchang 14y agoIf you use Knockout please consider being more vocal about it. It is a fantastic mini-framework/library but doesn't have the crazy PR behind it like backbone. Angular is great but the problem is you really need to use client side templating for it to be useful. It also has the same syntax as django's template language by default. All this is workable but Angular is great for projects that you are starting. Knockout is better to integrate with existing projects.
- nateweiss 14y agoThanks to all in this part of the thread for talking so pretty about Knockout - it got me to try incorporating it tonight on a simple interactive page I started recently, and it's a pleasure to use so far. Works nicely in combination with coffeekup, which I also enjoy a lot.
- SoapSeller 14y agoYeah, knockout is great. And it's relatively(to angular) easy to understand what's going on. Also, in my tests for an app(PhoneGap) I did recently, it seems much faster than angular(rendering seems to take half the time)
- hackerboos 14y agoKnockout's tutorials are great.
- krebby 14y agoWhat don't you like about Backbone? I never hear anything constructive or even a solidly coherent argument from its detractors
- SoapSeller 14y agoBackbone is pretty much a classic MVC, You define your data-model, your views(HTML) and than connecting all together in the controller. It's an old and trusty way of doing GUI, but it require you to define your UI(views) in two places - HTML and js code. You must have hardcoded HTML references in your JS code(via CSS selectors & etc), and for every change you do in your view you have to check(and probably change) your js code as well - and vice versa. Where in MVVM based frameworks(e.g. knockout) you define your view only once - in your HTML file. Your view contains everything that is needed to render the data in your View Model, and can initiate changes to the view model(and render any change that is being made to the date in the view model). There is never a need to use hardcoded references to the HTML in your js code.
- politician 14y agoThere is a multitude of two-way DOM data binding add-ons for Backbone.
- ganarajpr 14y agoGet jashkenas or the people behind Backbone to write a data-binding plugin.. I guess, I will consider BB for data-binding then. I have tried most of the data-binding plugins in backbone.. They all fall short one way or the other. Stickit does not deal with collections, model-binder does but is a pain in the ass to use properly. Rivetjs seems better than the other two - but the scariest part of backbone plugins is that the community behind each is extremely small -hence its scary to consider them.
- nailer 14y agoOfficial docs are terrible. Other sources are better but not maintained with the current release.
- krebby 14y agoWhat does Knockout, Angular, et al give you that Backbone doesn't? It seems like most of the anti-Backbone comments are about it being unable to "scale", which is funny considering Hulu, Trello, SoundCloud and about a hundred other very large apps use it just fine. I have yet to see any of the other frameworks deployed to the that scale at all (where are the examples?)
- lucisferre 14y agoWhat they give you actual two-way binding for DOM manipulation and rendering between client and model. They also, generally speaking, place very few requirements on your model which is a very good thing. Angular is exceptionally flexible and one of the first tools for building client-side JS that really impressed me. That said it is fairly complex (and not that well documented) when compared to Backbone, so I can understand why not everyone would be impressed. Cavet emptor. As an alternative Knockout is pretty simple, it's just not my thing. Backbone is a neat tool and what it provides most people is a somewhat predefined structure to work in. Coloring between the lines is really useful. However (as the parent said) it really does very little other than that in the end really. There is almost nothing that Backbone does that a sensible use of jQuery binding and data attributes can't do as well or better. It's just that most people will find it easier to learn Backbone, which is great don't get me wrong, but don't be surprised to find people (like myself) who have moved on. (Also the way model are done is terrible, I've never liked it it always got in the way of whatever I was trying to do.)
- krebby 14y agoTwo-way binding is a neat trick, but I hate that it clutters my markup, and almost always I need to augment it in some way. Backbone's declarative events hash is universally a better way to go for that.
- ganarajpr 14y agoCan you please make any other sane argument other than "it clutters my markup"? You are holding the markup to a standard which seems like there is someone out there handing out "The best clean and clutter free markup" award. End of the day you need to somehow hook up js and html. There is no second question to that. If you shovel out all the shit from html guess where it will land? In your js ( all the dom manipulation code!).