Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
KNOCKOUTJS BLUEPRINTS

You're reading from   KNOCKOUTJS BLUEPRINTS Learn how to design and create amazing web applications using KnockoutJS

Arrow left icon
Product type Paperback
Published in Feb 2015
Publisher
ISBN-13 9781783980840
Length 218 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Carlo Russo Carlo Russo
Author Profile Icon Carlo Russo
Carlo Russo
Arrow right icon
View More author details
Toc

Getting jQuery because it can be useful

In the previous section, we put the data directly inside the View Model; this was just to show how the ViewModel works. In any normal application the source of your data is online and you get it by calling a remote service.

Anyway, as you can see if you look at the documentation of KnockoutJS, the library doesn't provide you any help to take the data. We could use plain JavaScript to do this; but to make it a little easier, we will be using jQuery to deal with our AJAX request in the rest of the book.

Browser compatibility

One of the most relevant features of KnockoutJS is its browser compatibility; it even works on ancient browsers, so you can use it if you need to support them.

When you develop a big application to be used online you have to decide which browser you're going to support; the main reason is that each browser you decide to support means:

  • Testing on it
  • Checking if your code/style sheet/HTML page can be supported, and how

For this reason, many big companies keep an eye on the browser market share data; it helps you to decide if it's time to drop support for a particular browser.

I mentioned this here because we are going to use jQuery. This library is different from KnockoutJS, because you must choose between two branches: 1.x and 2.x.

The main difference here is the compatibility; if you want to support all the browsers KnockoutJS supports you have to download the 1.x branch, otherwise you can choose 2.x.

Note

For these chapters, we will use the 1.x branch (we will use 1.11.1). You can download the latest jQuery library here: http://code.jquery.com/jquery-1.11.1.min.js.

After you download it, save it as SimpleShowCase/js/jquery.js.

Then update the index page to include it before the row where we included KnockoutJS:

    </div>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/knockout.js"></script>
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image