【发布时间】:2023-03-11 18:35:01
【问题描述】:
我正在尝试使用 kendo-ui mobile 和 phonegap 开发一个购物车系统。首先,我在列表视图中列出所有项目。在每个listview项目中,会有一个加号按钮、减号按钮和一个标签。我使用这个组合来选择项目的数量。所以,如果我们点击加号按钮,标签值应该是0+1=>1和当我们点击减号时,它应该是 1-1=>0 。点击按钮时要更改标签的值,我通过标签的 id 来更改相应的标签值。但我无法将 html 的 id 表单传递给 javascript,就像我在 Web 开发中所做的那样。这是我的代码,
我的列表视图项模板,
<script type="text/x-kendo-tmpl" id="endless-scrolling-template">
<div class="product">
<img src="images/image.jpg" alt="#=ProductName# image" class="pullImage"/>
<h3>#:ProductName#</h3>
<p>$#:kendo.toString(UnitPrice, "c")#</p>
<a id="minus" data-role="button" data-click="minus(#:ProductID#)" >-</a>
<label id=#:ProductID#>0</label>
<a id="plus" data-role="button" data-click="plus(#:ProductID#)" data-name="plus">+</a>
<a id="loginButton" data-role="button" data-click="login">Add to Cart</a>
<div class="console"></div>
</div>
还有我的 javascript 函数,
<script>
function plus(itemid) {
var quantity=document.getElementById(itemid).innerHTML;
document.getElementById(itemid).textContent = parseInt(quantity)+1;
}
function minus(itemid) {
var quantity=document.getElementById(itemid).innerHTML;
document.getElementById(itemid).textContent = parseInt(quantity)-1;
}
</script>
谁能告诉我我在这里做错了什么?或者您能提供替代解决方案吗?
【问题讨论】:
标签: android cordova kendo-ui kendo-mobile