jQuery MiniColors 색상 선택 도구 (http://labs.abeautifulsite.net/jquery-minicolors/)가 Aurelia 데이터 바인딩에서 올바르게 작동하지 않는 것 같습니다.Aurelia 바인딩이있는 jQuery MiniColors 사용
calendar.html (템플릿) :
<!-- src/settings/school/calendars -->
<template>
<require from="jquery-minicolors/jquery.minicolors.css"></require>
<form>
<div class="form-group">
<label class="control-label" for="cal_name_orig"><span t="Calendar_name"></span></label>
<input type="text" class="form-control" ref="cal_name_orig" value.bind="calendar.cal_name_orig & validate" />
</div>
<div class="form-group">
<label class="control-label" for="cal_color"><span t="Color"></span></label>
<input type="text" id="cal_color" class="form-control" value.bind="calendar.cal_color">
</div>
</form>
</template>
그리고 내 calendar.js (뷰 - 모델) 두 가지가 있습니다
//src/settings/school/calendars.js
import 'jquery-minicolors';
export class SettingsSchoolCalendars {
error = null;
selectedId = null;
calendar = {};
attached() {
var self = this;
// set focus when modal is shown
$("#cal_color").minicolors({
control: "wheel",
theme: "bootstrap",
});
}
}
형태로 제어 작동하지만 바인딩 문제 :
calendar.cal_color 값은 입력에 나타나지만 색상 선택기의 색상은 설정하지 않습니다.
색 선택기 색을 변경하면 새 값이 입력에 나타나지만 바인딩 된 값인 calendar.cal_color는 업데이트되지 않습니다.
jQuery MiniColors는 입력 컨트롤의 value.bind 속성을 사용하고 있습니까? 다른 설명이 있습니까?
I 성공적 모델이 MiniColors 인스턴스화이를 추가하여 업데이트 할 수 있습니다 :
change: function(hex, opacity) {
self.calendar.cal_color = hex;
}
을하지만, 내가 반대 할 수가 없어합니다 (MiniColors 컨트롤을 업데이트 할 때 모델 변경). 그리고 여전히 초기 색을 올바르게로드하지 않습니다.
도움말!
당신 '$ ("# cal_color") ...''참조를 얻으려면'ref' 속성을 사용해야합니다 VM에서 참조하려는 요소로 이동하십시오. '