Not sure if Ember.js is the right tool for the job

Hello, everyone!

I’ve been working with Ember.js for about two weeks, and right now I’m starting to feel the slight buyer’s regret one feels when they start to think they might’ve invested too much time into a wrong choice.

My goal is to develop one app inside a larger application. This app is an actual single-page app, there won’t be any navigation at all. It’s just one page, a few tables where the user will perform queries and select items, and then the user will submit and the data will be handled and stored properly by the server. The backend is a Django application, and all queries are handled by Tastypie (which has been lovely to work with). Since it’s single-page, I need to figure out how to do simple things that are very easy to do with jQuery but become a unmantainable spaghetti mess very quick.

This is actually a rewrite – the first version of this application was written by a different developer, and was a slow mess of thousands of lines of ad-hoc JavaScript, jQuery and Backbone code. I had heard many good things about Ember, and thought maybe it would be perfect to replace all that with faster and more better-organized code.

My main problem is that I haven’t yet figured out how to handle some kinds of state changes and to add and handle events. A simple “populate this table with results from a API call with a parameter chosen by clicking an option from a jQuery Autocomplete field” took me a long time to get almost-right, and it has left me weary that I might’ve picked a framework that’s not very well-suited to the job – either that or I haven’t been able to figure out how to “think in Ember” and see how to do the things I want to. Most tutorials and screencasts handle fetching and displaying data by navigating to urls and {{link-to}} tags, which is problematic for me because I’m not actually navigating – it should be just event-handling, attribute binding and some AJAX requests.

I’m sorry if I wasn’t able to make a lot of sense – I’m an ESL speaker and I don’t have much experience with Ember (and JavaScript in general), so my terminology might be a little off.

Thanks a lot for reading :slight_smile:

Hey @roddds

Just after an initial pass at reading what you’re trying to do, I’d say that Ember still might be a really good solution for you. My first piece of advice as you embark on this comes from the ember guides here:

Finally, if you don’t want the browser’s URL to interact with your application at all, you can disable the location API entirely. This is useful for testing, or when you need to manage state with your Router, but temporarily don’t want it to muck with the URL (for example when you embed your application in a larger page).

App.Router.reopen({
  location: 'none'
});

The URL really only acts as a way of serializing/representing the current state of your application…but it doesn’t have to be used at all.

You can, and still should, use the Ember router, {{link-to}} tags, etc, as this is the perhaps the best part of Ember. Try to think of your application as if you would be using URLs…but just don’t use them.

My two cents anyway.

Hope this helps!

1 Like

Wait, so does that mean that I can use routes to trigger actions, but those actions won’t get undone if I “navigate” away? If I understand correctly, the routes are used mainly to “rebuild” the state of the application, but you could, for example, have two {{link-to}} tags that trigger the rendering of separate named {{outlet}}s without one “undoing” the other?

I come from a backend background, so for me it’s kind of difficult to grasp this kind of difference – in my head, you either render everything at once, passing the relevant variables to the context, or you use ad-hoc jQuery queries and DOM updates.

1 Like

I’m not sure I understand what you mean by this. Do you mean leaving the page entirely? If so, and you aren’t using the URL to represent the state, then, yes, you would lose the state of the application (though I suppose, you could still manage to do that using local storage or something).

But, in regards to the other question: yes, you can have separate named outlets that could exist independently of one another and are controlled by different controllers that can each have their own state and would not undo each other as actions are taken.