LaceySnr.com - Salesforce Development Posts by Matt Lacey

Get Started With KnockoutJS on the Salesforce1 Platform

Posted: 2014-11-14

Anyone who's talked with me (or heard me talk) over the last 6 months are so is likely to have heard me sing the praises of KnockoutJS, not least during the presentation I did with Chris Bland at Dreamforce this year. There is a veritable smorgasbord of Javascript libraries around these days, and there's more than a few that I like, but right now, for me, KnockoutJS is the shining star, and if you're looking to build more dynamic pages inside of Salesforce1, then I highly recommend you take a look at it.

Why Use Javascript At All?

As more and more of Salesforce development revolves around the Salesforce1 mobile application, it's becoming increasingly obvious that roundtrips to the server with Visualforce are not the way to go, sending and receiving everything that's required for your controllers is slow, and so remoting is the way to do things. If you've not tried it already then you'll be surprised at just how fast it is when compared to the more traditional Visualforce techniques.

But I Love jQuery!

Sure, so do I. In fact, I'd go so far to say as the overwhelming majority of developers on the platform have used jQuery at some stage,  but it only goes so far. When it comes to dealing with updating data on your page and making everything reactive in real time it can get unweildy very quickly, which is why there are frameworks like Angular, Ember and Knockout.

Why KnockoutJS?

I've played with a few of these frameworks now, and they all have their strengths and weaknesses. The reason why I've become particulary fond of KnockoutJS is that it's designed to work really well with single page apps, and that's what the form that the majority of Salesforce1 mobile apps take. It also requires very little in the way of boilerplate code, and it keeps everything neat, compact, and compartmentalised,  and also happens to work very well with remoting.

Let's Get Started!

Sure, though not here in this post. As it happens I've written up a KnockoutJS workshop (which was originally intended to be content for Dreamforce) that is available on GitHub and takes you through the process of building a simple account rolodex from scratch.

Hopefully it conveys just how quickly you can put something together with KnockoutJS, and also how little effort it takes to hook things up. Sure the CSS is a tad ugly, but check it out and let me know what you think, all feedback is appreciated!

Related Posts