0

I'm using backbone.js for my mobile app project. My question is, how i can get value from url parameter then display on page?

js

define(['jquery', 'underscore', 'backbone','text!templates/attribute/attributeValueIndexTemplate.html'], function($, _, Backbone,attributeValueIndexTemplate) {
    var AttributeValueIndexView = Backbone.View.extend({
        el: $("#page"),
        initialize: function() {
            this.$el.off();
        },
        render: function(attributeId) {
            this.$el.html(attributeValueIndexTemplate);
        }
    });
    return AttributeValueIndexView;
});
Nurdin
  • 23,382
  • 43
  • 130
  • 308

1 Answers1

1

For that, you typically use a router and react to routing events, passing in the parsed URL parameters. See http://adrianmejia.com/blog/2012/09/13/backbone-js-for-absolute-beginners-getting-started-part-4/

Note that you can also access the URL parameters "by hand" using window.location.search but that is not the best way to do it in Backbone.

David Sulc
  • 25,946
  • 3
  • 52
  • 54