T
T
thalwho2016-12-08 13:09:34
backbone.js
thalwho, 2016-12-08 13:09:34

How to make old code work in new version of backbone.js?

var Start = Backbone.View.extend({
    el: $("#start"), // DOM элемент widget'а
    events: {
        "click input:button": "check" // Обработчик клика на кнопке "Проверить"
    },
    check: function () {
        if (this.el.find("input:text").val() == "test") // Проверка текста
            controller.navigate("success", true); // переход на страницу success
        else
            controller.navigate("error", true); // переход на страницу error
    }
});

var start = new Start();

This is from the guide for dummies, on Habré. I downloaded the latest versions, the code does not work, no errors - nothing. How to fix it to make it work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2016-12-08
@thalwho

this.el.findshould be this.$el.find.
Plus, check that the element with id start exists on the page at the time the script is called.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question