agilityjs
というテーブルを持つ というデータベースを作成しましたtodolist
。/api/todolist.php
Web サービスとして機能するファイルを作成しました。ユーザーが「新しいアイテム」をクリックすると、PHP ファイル ( ) を呼び出して新しいアイテムがデータベースに追加されるようにしたいと考えていますtodolist.php
。私の次の目標は、クリックして編集するときにアイテムを編集し、クリックして削除するときに削除することです。
誰でも正しい方向に私を助けることができますか? http://agilityjs.com/docs/docs.html#persistで持続性のドキュメントを見たことがありますが、適用方法がわかりません。
次のコードは、http://agilityjs.com/から単純に取得したものです (下部に表示されているのがライブ デモです)。
https://gist.github.com/3166678を学習するための別の優れたリソースを次に示しますが、それも適用できないようです。
//
// Item prototype
//
var item = $$({}, '<li><span data-bind="content"/> <button>x</button></li>', '& span { cursor:pointer; }', {
'click span': function(){
var input = prompt('Edit to-do item:', this.model.get('content'));
if (!input) return;
this.model.set({content:input});
},
'click button': function(){
this.destroy();
}
});
//
// List of items
//
var list = $$({}, '<div> <button id="new">New item</button> <ul></ul> </div>', {
'click #new': function(){
var newItem = $$(item, {content:'Click to edit'});
this.append(newItem, 'ul'); // add to container, appending at <ul>
}
});
$$.document.append(list);
ありがとうございました。