我在这里找到了代码,但它不提供插入数据库
http://www.spicevanjava.nl/tech-talk/shopping-cart-ui-demo-mobile-version/
这里是示例
index.html
<script type="text/template" id="submit-btn-tmpl">
<button data-icon="arrow-d" data-theme="b" id="submit-btn">Submit</button>
</script>
购物车.js
// Submit Button
var SubmitButton = Backbone.View.extend({
el: '.basket-footer',
//get template
template: $('#submit-btn-tmpl').template(),
appRouter: null,
initialize: function() {
// set appRouter
this.appRouter = this.options.appRouter;
},
render : function () {
var totalPrice = 0
// get total price
if (this.appRouter.basketItems.length > 0)
totalPrice = this.appRouter.basketItems.totalPrice();
// clean up
$('#submit-btn').remove();
// and finally render this view with total price
$(this.el).append($.tmpl(this.template, {price:totalPrice}));
}
});