I have a dust.js template that renders inputs based on a hash I am getting from the server. My hangup is that if the hash is empty I still get an input box rendered with an empty placeholder value, how can I check if the placeholder value is null and then hide that box?
<div class='criteria-input'>
<input type='text' placeholder='{attribute}' value='{value}' size='20'/>
<span class="close">X</span>
</div>
I have a dust.js template that renders inputs based on a hash I am getting from the server. My hangup is that if the hash is empty I still get an input box rendered with an empty placeholder value, how can I check if the placeholder value is null and then hide that box?
<div class='criteria-input'>
<input type='text' placeholder='{attribute}' value='{value}' size='20'/>
<span class="close">X</span>
</div>
Share
Improve this question
edited Jul 22, 2014 at 19:46
glortho
13.2k8 gold badges51 silver badges46 bronze badges
asked Jul 22, 2014 at 19:30
mrtrianglemrtriangle
54411 silver badges28 bronze badges
3 Answers
Reset to default 3See the "Special Sections" documentation of dust.js here: http://akdubya.github.io/dustjs/#guide
The "exists" syntax is what you want, so that you can do this:
{?attribute}
<div class='criteria-input'>
<input type='text' placeholder='{attribute}' value='{value}' size='20'/>
<span class="close">X</span>
</div>
{/attribute}
here you go:
$('input').each(function(){
if($(this).attr('placeholder')=='' || $(this).attr('placeholder')==null){
$(this).parent().hide();
}
});
here is the code that checks if the placeholder is empy
var placeholder = $('input').attr('placeholder');
if(placeholder == ''){
} else{
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745100213a4611227.html
评论列表(0条)