Knockout Tutorial: Build Dynamic, Interactive Web Pages Easily

  You are currently not logged in. You can view the forums, but cannot post messages. Log In | Register

25-Jun-12 00:00
This is a forum topic for discussing the article "Knockout Tutorial: Build Dynamic, Interactive Web Pages Easily":

http://www.elated.com/articles/knockout-tutorial/

Learn to use the powerful Knockout JavaScript library to quickly create interactive user interfaces for your websites and web apps. Lots of example code is included in the tutorial.
25-Jun-12 19:50
Thanks for such a comprehensive article on Knockout...
I'm currently checking out the various options with all these wonderful Javascript frameworks available. But one thing that has me stumped is how to integrate them with database's (receiving the data, updating the data etc...)
Almost all of them say something like you have:
"Normally this would be pulled dynamically from a database using a server-side script (such as PHP), but to keep things simple we'll create a static text file instead"
But it seems difficult to find a real world example which demonstrates how this is done.
Hope you can provide some feedback on this...
Best Regards, Dave
26-Jun-12 02:34
@daveporter: Thanks for your comment. That's a good question. Essentially you'd have, for example, a MySQL database on the server, and a PHP script that runs a SELECT query on the DB to pull out the product data, then format it as a JSON string using http://php.net/manual/en/function.json-encode.php and send that back to the browser.

To go the other way, you'd use http://php.net/manual/en/function.json-decode.php to decode the JSON string that currently appears in the alert box when you press Buy Now, then do something useful with it (such as create a record in an 'orders' table etc).

Hard to summarise in a couple of paragraphs! Maybe I'll write an "end-to-end" tutorial explaining the process at some point...

--
Matt Doyle, Elated
3rd Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/
26-Jun-12 02:51
Cheers Matt - I'll look forward to that...
Regards, Dave

 
New posts
Old posts

Follow Elated