我正在从数据库中获取记录并将其打印在表上。见图片:
对于设备权限列,我想使用 Button 如果值为“true”,则显示 Disapproved(表示设备已获批准),并且 OnClick 我想调用一个函数,该函数将针对 IMEI 更新值“false”到数据库(意味着现在设备不赞成使用).. 同样,如果值为false我想显示一个按钮,该按钮将显示 Approve 表示点击它我想调用一个函数来更新值true在 数据库中针对该 IMEI的错误位置。代码是:
<script type="text/javascript">
/**
* This code declares your class and saves an object "blogentry" to the table on StackMob.
* StackMob will create the table for you automatically based on your JSON.
*/
$(document).ready(function() {
result();
function result() {
var device = StackMob.Model.extend({ schemaName: 'device' });
var mydevice = new device({ });
var q = new StackMob.Collection.Query();
q.equals('device_org', 1);
q.setRange(0,9).orderDesc('lastmoddate');
mydevice.query(q, {
success: function(modal) {
//After StackMob returns "Bill Watterson", print out the result
var array = modal.toJSON();
// console.debug(array);
//$('#data').html(array[0].user_name);
var val = array[0].lastmoddate;
$('#last_mod_date').attr('value', val);
var key;
var count = 0;
for(key in array) {
if(array.hasOwnProperty(key)) {
count ++;
}
}
//alert(count);
for(var i=0; i<=count; i++)
{
// if(array[i].org_img == localStorage.getItem("stackmob.oauth2.user"))
//alert(array[i].org_img);
//$('#last_mod_date').html(array[0].lastmoddate);
//alert(val);
$("#ui").append("<tr><td>"+array[i].device_IMEI+"</td><td>"+array[i].device_model+"</td><td>"+array[i].device_permission+"</td><td>"+array[i].device_nickname+"</td><td>"+ new Date(array[i].lastmoddate)+"</td><tr>");
//end if condition
} // end for loop
} //end success
}); // end imagesearch schema query
} // end result function
setInterval(check_newentry,1000);
function check_newentry() {
var device = StackMob.Model.extend({ schemaName: 'device' });
var mydevice = new device({ });
var q = new StackMob.Collection.Query();
q.orderDesc('lastmoddate');
mydevice.query(q, {
success: function(modal) {
//After StackMob returns "Bill Watterson", print out the result
var array = modal.toJSON();
// console.debug(array);
//$('#data').html(array[0].user_name);
// alert(lastmod_date_old +"..."+ lastmod_date);
if(lastmod_date_old < lastmod_date)
{
var val = array[0].lastmoddate;
$('#last_mod_date').attr('value', val);
var key;
var count = 0;
var counter=0;
for(key in array) {
if(array.hasOwnProperty(key)) {
count ++;
}
}
//alert(count);
for(var i=0; i<=count; i++)
{
if(counter<50)
{
$("#ui").append("<tr><td>"+array[i].device_IMEI+"</td><td>"+array[i].device_model+"</td><td>"+array[i].device_permission+"</td><td></td>"+array[i].device_nickname+"<td>"+new Date(array[i].lastmoddate)+"</td><tr>");
//------------------------------------------- end device schema code
counter++;
}
else
exit();
}
}
}
});
} // end check_newentry
});
</script>
所以我的问题是:1.我怎样才能把按钮放在上面描述的状态。2.单击“已批准/未批准按钮”时如何调用函数以及如何仅访问单击按钮的行值..提前谢谢!