2016-07-21 3 views
0

jQuery를 사용하여 .mustache 파일에서 DIV ID를 읽는 방법은 무엇입니까?jquery와 콧수염을 사용하는 canjs

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(); 
} 

("드래그.")) (드래그.; 작동 안됨.

+0

템플릿이 렌더링 되었습니까? –

답변

0

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(); 

내가 (당신이 .draggable 전화를 할 수있을 것입니다 생각하지 않습니다 당신은 jQuery를 filter()를 사용하여 렌더링 템플릿의 요소에 액세스 할 수 있습니다) 요소가 DOM에 렌더링 될 때까지 요소에 적용됩니다.

filter()here에 대해 자세히 알아보십시오.