Como ler um ID DIV de um arquivo .mustache usando jQuery?
por exemplo. asdf.mustache
<div class="draggable">
<p>drag this here</p>
</div>
adminControl.js
define(["jQuery", "can", "ctbConfig","labelsConfig"], function(jQuery, can, ctbConfig,labelsConfig) {
$(".draggable").draggable();
}
Aqui $ (". Draggable"). Draggable (); não está funcionando.
Respostas:
0 para resposta № 1Você pode acessar elementos em um modelo renderizado usando jQuery filter()
var template = "<div class="draggable"> <p>drag this here</p></div>";
var html = Mustache.render(template, {});
// Use filter to get the element .draggable
$(html).filter(".draggable").draggable();
Eu não acho que você será capaz de chamar .draggable (); no elemento até que seja processado para o DOM.
Leia mais sobre filter()
Aqui.