A
A
Alexander Fadeev2012-03-02 09:45:27
css
Alexander Fadeev, 2012-03-02 09:45:27

Dust template engine: images from css are not loaded after inserting a template

All hello.

The project structure is as follows:
backbone - MVC
Dust -
Mootools template engine - operations with DOM
LESS - CSS generation

Actually, the essence is this. I load via JSON and compile using the dust template. Then, using mootools, I insert it into the page:

new Request.JSON({url: 'templates/basis.json',
   onFailure: function(){
      console.log('error');
   },
   onSuccess: function(responseJSON){

      dust.loadSource(dust.compile(responseJSON.basis, "intro"));
   
      dust.render("intro", {name: "Fred"}, function(err, out) {
         $('init').set('html', out);
         return out;
    });
}).get();


By the time the finished template is inserted into the page, the compiled styles are already hanging in the browser. And here's the big catch: all styles are applied except for assigning a background image .

What could be the problem?

UPD: hmm. Solution found. Background images should not have background-repeat specified on one of the axes or missing. That is, this attribute must be either not specified at all, or simply be repeat. Very strange behavior, to be honest.

UPD2: In general, the problem turned out to be my inattention. It's a pity that I spent so much time on this, because initially I was looking in the wrong place.
In fact, the problem was in the css: an attribute from another block (background-position: 0 80px;) was accidentally transferred, due to which the image was not visible. Everything turned out to be stupid. =) If I had immediately paid attention to this, I would have saved a few hours ...
And everything else works with a bang, as expected. =)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2012-03-03
@Ualde

Try adding "!important" to the background image loading. Possibly override existing styles.

S
spmbt, 2012-03-03
@spmbt

Perhaps an error with a relative path to the image .. If you register an absolute, does it work?

A
Alexander Fadeev, 2012-03-03
@AlexFadeev

In general, the problem turned out to be my inattention. It's a pity that I spent so much time on this, because initially I was looking in the wrong place.
In fact, the problem was in the css: an attribute from another block (background-position: 0 80px;) was accidentally transferred, due to which the image was not visible. Everything turned out to be stupid. =) If I had immediately paid attention to this, I would have saved a few hours ...
And everything else works with a bang, as expected. =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question