Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you followed some tutorial, since both beforeRender and afterRender don't exist in Backbone core. But, they are often implemented by people who need events fired before and after the rendering routine.</p> <p>Moreover, Backbone leaves the render function of the View class empty, so it's up to you to implement (and even call it) when you need.</p> <p>As a sidenote, it's generally not good to call render() right into the initialize() function, since often you'll need to have more control on when and how to render a view after having initialized it.</p> <p>That said, I would suggest: </p> <ul> <li>Move all of the initialization logic (like your navigator checks) inside initialize();</li> <li>call render() out of the view (right after your new ViewName() call)</li> </ul> <p>If you really need (maybe for further development of your code) <em>before</em> and <em>after</em> callbacks, you can make use of Underscore (available since it's a dependency) "wrap" function. Such approach consists of:</p> <pre><code>initialize: function() this.render = _.wrap(this.render, function(render) { this.beforeRender(); render(); this.afterRender(); }); }, render: function() {}, beforeRender: function() {}, afterRender: function() {} </code></pre> <p>With this in mind, I would go with (remember to specify an <em>onFailUpdatePos</em> on the View class): </p> <pre><code>initialize: function() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(this.render, this.onFailUpdatePos); } else { navigator.geolocation.getCurrentPosition(this.render, this.onFailUpdatePos); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload