0
中的更改im試圖查看發送到函數cronSave(user_id,script_id,cron_format)
的值。問題是cron_format
是<contenteditable>
屬性和功能將僅顯示值innitialized表沒有得到的變化.. 這是表:ng-click不會識別表
<p id="demo">Display data here</p>
<main>
<table class="table table-bordered table-hover" ng-controller="tableCtrl">
<thead>
<th>user name</th>
<th>script name</th>
<th>cron format<span class="glyphicon glyphicon-question-sign"></span></th>
</thead>
<tbody>
<tr ng-repeat="row in data">
<td class="userName">{{row.user_id}}</td>
<td class="scriptName">{{row.script_id}}</td>
<td class="cronFormat"><span contenteditable="true" ng-repeat="l in letters(row.cron_format) track by $index">{{l}}</span><button class="save" ng-click="saveCron(user_id,script_id,cron_format)">save</button></td>
</tbody>
</table>
</main>
,這是JS:
var app = angular.module('app', []);
//Table Controller
app.controller('tableCtrl',function($scope) {
$scope.data = [
{user_id: "1", script_id: "s12", cron_format: "*/2 * * 5 *"},
{user_id: "2", script_id: "s34", cron_format: "*/5 * * * *"},
{user_id: "3", script_id: "s54", cron_format: "*/4 * 7 * *"},
{user_id: "4", script_id: "s234", cron_format: "*/6 * * * *" }
];
//parse cron_format and edit each digit individually
$scope.letters = function(row.cron_format){
return cron_format.split(" ");
}
//save cron changes if exits/create if doesn't
$scope.saveCron = function(userId,scriptId,cronFormat){
$.post("updateCronChange.php","user_id=userId&script_id=scriptId&cron=cronFormat", function(data){
document.getElementById("demo").innerHTML = userId + scriptId + cronFormat; // Get the element with id="demo"
});
}
});
所以如果在一個行用戶改變的cron格式*/5 * * *
它將在"demo"
*/2 * * 5 *
感謝您的幫助,但仍然...它不會改變cron_format的值不更新的事實 – 2015-02-12 09:43:28
@johnking對不起,錯過了,看看編輯。 – 2015-02-12 09:59:29
作品完美謝謝! – 2015-02-12 10:32:05