Last active
December 23, 2015 04:09
-
-
Save mekkoo/6577909 to your computer and use it in GitHub Desktop.
render.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
$(function(){ | |
// var items = []; | |
var pages,pages_items = {}; | |
$.ajax({ | |
url: '../pages.json', | |
dataType: 'json', | |
success : function(data){ | |
pages = data; | |
pages_items = data.items; | |
$('#add-obj').click(function() { | |
// pagesを監視(observe)しつつ、要素を追加 | |
$.observable(pages).items.insert(pages.length, { | |
"item": { | |
"id": 1807, | |
"item_name": "あいうえお1", | |
"item_desc": "com", | |
"item_img": "http://example.com/sample.png" | |
}, | |
"values": [ | |
{ | |
"id": 18406, | |
"key_id": 344, | |
"value": "ドコモ" | |
}, | |
{ | |
"id": 1, | |
"key_id": 1, | |
"value": "AAA-AAAA" | |
}, | |
{ | |
"id": 2, | |
"key_id": 2, | |
"value": "30g" | |
} | |
] | |
}); | |
}); | |
}, | |
complete : function(){ | |
// テンプレートに名前をつけて登録する | |
$.templates({ | |
linkTemplate: "#template" | |
}); | |
// テンプレートlinkTemplate(#template)と変数pagesをリンクさせ、 | |
// レンダリング結果をid="render"に表示 | |
$.when($.link.linkTemplate("#render", pages)).done( | |
function() { | |
//$.whenでjsrenderのレンダリングメソッドをラッピングし、 | |
//done(描画完了時)にeditableを起動。 | |
//editableOptions()の本体はbootstrap-editable-options.js | |
editableOptions(pages.page_info.id); //比較表のpageIDを引数として渡し、bootstrap-editable-options.js内で利用 | |
dataTablesOptions(); | |
} | |
); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment