2014-10-02 3 views
0

나는 html multiselect 구현을 어떻게 자바 스크립트에서 녹아웃 데이터 바인딩을 구현합니까?녹아웃 js에 multiselect 바인딩

<select class='multiselect' data-bind=" 
             options: vm.types, 
             value: vm.selectedTypeId, 
             optionsText:'type', 
           optionsValue: 'typeId'"> 
           </select>" 
+0

데이터 바인딩을 자바 스크립트에서 사용 하시겠습니까? 만약 당신이 내게 intersted 무엇 attst() 함수를 사용하여 그렇게 할 수있을 것 같아요 –

+0

@ G_S, 네, 자바 스크립트에서 데이터 바인딩을 사용하고 싶지만 계산 Observables를 사용하는 것 같아요 – user2644776

+0

당신은 이것을 의미합니까 : http : // knockoutjs. com/documentation/selectedOptions-binding.html –

답변

0

다음과 같이 할 수 있습니다. 정확히 원하는 코드 나 작동 코드가 아닐 수도 있습니다. 하지만 그냥 샘플. document.ready 함수에서 이것을 작성하십시오. 필자가 쓴 것은 태그 스팬이 있다고 가정합니다. 해당 범위에 데이터 바인딩을 추가합니다.

var span=document.getElementsByTagName("span")[0]; 
var att=document.createAttribute("data-bind"); 
att.value="text: yourknockoutOBservable"; 
span.setAttributeNode(att);