Hyphen in class name issues

2 views
Skip to first unread message

MaxOfLondon

unread,
Dec 26, 2015, 4:36:02 PM12/26/15
to JavaScript Templates Engine PURE
Hi,

Seems that hyphen in class name is causing some issues. I've seen similar post about data containing hyphen in json names which was recorded as a bugs (bug 7) but I could't find bug entry on GitHub to see if it was resolved.

Anyway, I am getting 'The node "gallery-1" was not found in the template:' error using following:

[code]
<div class="gallery">
<div class="container">
<h3>Our Gallery</h3>
<div class="gallery-bottom">
<div class="gallery-1">
<div class="col-md-3 gallery-grid">
<a class="example-image-link" href="" data-lightbox="example-set" data-title=""><img class="example-image" src="" alt=""/></a>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>


var directive = {
'gallery-1': {
'image<-images': {
'gallery-grid': {
'a':'image.label',
'a@href':'image.image',
'a.img@href':'image.thumb'
}
}
}
};
$('.gallery-bottom').render(response, directive);

with json response' input:
{"images":[{"image":"images\/gallery1\/oakfloorboards 02-sanding.1.jpg","thumb":"images\/gallery1\/oakfloorboards 02-sanding.1-thumb.jpg","label":"oakfloorboards 02. sanding"},{"image":"images\/gallery1\/oak_floorboards-satin_finish.2.jpg","thumb":"images\/gallery1\/oak_floorboards-satin_finish.2-thumb.jpg","label":"oak floorboards. satin finish"},{"image":"images\/gallery1\/manor-finished.012.JPEG","thumb":"images\/gallery1\/manor-finished.012-thumb.jpg","label":"manor. finished"}]}




I am new to PURE so I might be doing something wrong here so would appreciate any corrections.

Thanks,
Max

Mic (BeeBole)

unread,
Dec 27, 2015, 4:11:44 AM12/27/15
to JavaScript Templates Engine PURE
Hi Max,

It is not related to the hyphen in your class name.
But a wrong selector.

When you want to select with a class, you need to use a dot before the classname.
Like you probably do in your CSS

eg:  '.gallery-1':{ ...

MaxOfLondon

unread,
Dec 27, 2015, 9:14:53 AM12/27/15
to JavaScript Templates Engine PURE
Thanks Mic for quick reply. Whole directive was also wrong for the purpose I wanted. It is working now:
var directive = {
'.gallery-grid': {
'image<-images': {
'a@data-title+':'image.label',
'a@href+':'image.image',
'a img@src+':'image.thumb'
}
}
};

$('.gallery-1').render(response, directive);

 
Reply all
Reply to author
Forward
0 new messages