Note that there are some explanatory texts on larger screens.

plurals
  1. POImage tag flickers then disappears - backbonejs
    primarykey
    data
    text
    <p>I am experiencing a strange behavior with backbone view, On my view template, the image tag flickers and then disappears immediately when the view is rendered, no image is then displayed this is my first backbonejs/nodejs application and I have spent quite some time trying to debug this,I hope I am clear enough, thanks.</p> <p>Here is my code:</p> <p>//The Backbone view</p> <pre><code>define(['text!templates/profile.html'],function(profileTemplate){ var profileView=Backbone.View.extend({ el:$('#content'), initialize:function(){ this.model.bind('change',this.render,this); }, viewTemplate: _.template(profileTemplate), render:function(){ this.model.fetch(); this.$el.html(this.viewTemplate(this.model.toJSON())); } }); return profileView; }); </code></pre> <p>//HTML TEMPLATE (profile.html)</p> <pre><code> &lt;img src="uploads/&lt;%= photo%&gt;" alt="image" /&gt; </code></pre> <p>//SCHEMA</p> <pre><code> var AccountSchema=new mongoose.Schema({ email:{type:String,unique:true}, password:{type:String}, name:{ first:{type:String}, last:{type:String}, }, photo:{type:String}, }); </code></pre> <p>Directory Structure</p> <pre><code>/ParentDirectory /Public /templates profile.html //this is the template being rendered /uploads //contains images </code></pre> <p>//ROUTER </p> <pre><code>define(['views/profile'],function(ProfileView){ var router=Backbone.Router.extend({ currentView:null, routes:{ "profile/:id":"profile" }, //Calls render method on views changeView:function(view){ if(null !=this.currentView){ this.currentView.undelegateEvents(); } this.currentView=view; this.currentView.render(); }, profile:function(id){ var model=new Account({id:id}); this.changeView(new ProfileView({model:model})); }, return new router(); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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. 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