Answer the question
In order to leave comments, you need to log in
Using if in a backbone/underscore template, how?
There is Backbone.View
to change the background of $el
:
var Background = Backbone.View.extend({
className: 'svs-widget svs-widget-animate',
events:{
'click .svs-upload-background': 'media'
},
initialize: function(){
},
render: function(){
this.$el.append(_.template(_background).apply(this.options));
return this.$el;
},
media: function(){
var me = this;
require(['View/Popup/Media'], function(_Media){
$.ajax({
url: '/svs-ajax.php',
type: 'post',
data: {
'action': 'change_bg'
},
success: function(data){
var media = new _Media({model: data, popup: popup, target: me.options.background});
var popup = new Popup({content: media.render()});
}
});
});
}
});
.svs-upload-background
I call Popup/Media
the template with the necessary media:<% if(this.data.length > 0){ %>
<div class="MediaList">
<img/>
</div>
<% } %>
Backbone.View
one that calls the same Popup/Media
template on click on.svs-upload-image
var Image = Backbone.View.extend({
className: 'svs-widget svs-widget-animate',
events:{
'click .svs-upload-image': 'media'
},
initialize: function(){
},
render: function(){
this.$el.append(_.template(_image).apply(this.options));
return this.$el;
},
media: function(){
var me = this;
require(['View/Popup/Media'], function(_Media){
$.ajax({
url: '/svs-ajax.php',
type: 'post',
data: {
'action': 'change_image'
},
success: function(data){
var media = new _Media({model: data, popup: popup, target: me.options.image});
var popup = new Popup({content: media.render()});
}
});
});
}
});
<% if(' **какой код нужен здесь?** '){%>
<div class="background_header">Изменения бэкграунда</div>
<% } %>
<% if(' **какой код нужен здесь?** '){%>
<div class="image_header">Измнение изображения</div>
<% } %>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question