Question

Hello stackoverflowers !!!

I have problem with render view after click event :

var TablesView = Backbone.View.extend({       

    events: {
      "click li" : "openMenuItem"
    },

    openMenuItem: function(e){
      currentLink = $(e.currentTarget);
      tableId = currentLink.data('table_id');
      app.navigate("table/" + tableId + "/menus");
      console.log("table/" + tableId + "/menus");
    },  

        initialize:function () {
        this.render();
    },
    render:function () {
        var that = this;
        var tables = new Tables();
        tables.fetch({
            success: function (tables) {
            var template = _.template($('#table-template').html(), {tables: tables.models});
              that.$el.html(template);
            }
        })
    }             
});

So when I click to one of my li I have in adress bar rigth adress but View is not changed, only when I click to adress bar and press enter ... (My url /table/:id/menus is function properly but is not opened with click event only when I have in template a link )

Thanks for answers... Regards

Was it helpful?

Solution

You forgot to pass trigger option:

app.navigate("table/" + tableId + "/menus", true); // or
app.navigate("table/" + tableId + "/menus", {trigger:true});

Of course if your app is an instance of Backbone.Router :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top