我从数据库中取出记录并将其打印在桌面上。 看图:
对于设备权限列,我想使用Button,如果值为“true”,将显示Disapproved(表示设备已获批准),OnClick on the button我想调用一个函数,该值将更新值“false” IMEI进入数据库(意味着现在设备变得令人失望使用)..同样如果值 false 我想显示一个按钮,它会显示单击它的批准方式我想要调用函数以在 false 的位置更新值 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.如何点击“已批准/不批准的按钮”时如何调用函数?如何只访问按钮被点击的行值...提前谢谢!!!