这是我第一次打bracket system。所以我谷歌的jquery支架系统。我找到了一个用于此目的的链接。并且对静态功能很有用。
我使用以下代码制作支架系统。
var customData = {
teams : [
[{name: "Team 1", flag: 'gg'}, {name: "Team 2", flag: 'gg'}],
[{name: "Team 3", flag: 'gg'}, {name: "Team 4", flag: 'gg'}]
],
results : [4,2]
}
/* Edit function is called when team label is clicked */
function edit_fn(container, data, doneCb) {
var input = $('<input type="text">')
input.val(data.name)
container.html(input)
input.focus()
input.blur(function() { doneCb({flag: data.flag, name: input.val()}) })
}
/* Render function is called for each team label when data is changed, data
* contains the data object given in init and belonging to this slot. */
function render_fn(container, data, score) {
if (!data.flag || !data.name)
return
container.append('<img src="images/'+data.flag+'.png" /> ').append(data.name)
}
$(function() {
$('#customHandlers .demo').bracket({
init: customData,
save: function(){}, /* without save() labels are disabled */
decorator: {edit: edit_fn,
render: render_fn}})
});
工作正常,但我想将结果动态存储到数据库中。 因为我是新人,所以我不知道如何做到这一点。