questions = new Altair.Collections.QuestionsCollection
assignments = new Altair.Collections.AssignmentsCollection
questions.reset(#{@assignment.questions.to_json})
assignments.reset(#{@assignment.to_json})
assignment = assignments.get(1)
answer = new Altair.Collections.AnswersCollection
$(function() {
render_question()
function bind_click(){
$('.anslink').click( function() {
ans = $(this).text()
question = $(this).parent().find(".question_id").val()
answer.create({'question_id' : question, 'answer' : ans})
})
}
function bind_submit(){
$('.nextquestion').click( function() {
assignment.fetch()
assignment.set({'current_id' : current + 1 })
assignment.save()
render_question()
})
}
function render_question(){
assignment.fetch()
current = assignment.get('current_id')
q = questions.get(current)
r = new Altair.Views.Questions.ShowView({'model': q})
r.render()
$('#question').html(r.$el.html())
rightWrong()
bind_click()
bind_submit()
}
}
Thursday, October 4, 2012
Backbone.js
I finished the UI for taking an exam. The Backbone code looks like this
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment