Thanks for your answers, but unfortunately I can’t understand. Nevertheless, I appreciate your input.
Finally, I resort to using the rivet.js library. This library provides an easy and powerful solution for data binding + templating to create modern web applications.
They have good documentation to help with development.
Now I can simply convert the data to representations like { data.someAttribute } , as in the following code fragment:
<section id="auction"> <h3>{ auction.product.name }</h3> <p>Current bid: { auction.currentBid | money }</p> <aside rv-if="auction.timeLeft | lt 120"> Hurry up! There is { auction.timeLeft | time } left. </aside> </section>
And then I can just bind the auction tag of section # with the auction JSON object like this:
rivets.bind($('#auction'), {auction: auction})
This made it easy to get my data from the server and create data templates in the views. Now the same web service can finally be used by mobile applications.
Hope this helps someone. :)
Rohan
source share