선택한 개체에 따라 텍스트를 표시하는 TinyMCE WYSiWYG 편집기가 있지만 바인딩에 문제가 있습니다.녹아웃 데이터 바인딩이있는 TinyMCE
첫 번째 "instanciation는"작동하는 것 같다,하지만 사용할 수있는 텍스트의 드롭 다운 목록에서 새 텍스트를 선택할 때 편집기 공백 상태와 파이어 버그 콘솔은 나에게 말한다 :
형식 오류 : D.hasChildNodes는 함수가 아닙니다 ... ute (i), "string"== typeof r) {try {r = "true"=== r?! 0 : "false"=== r?! 1 : "null"=== ? R 널 (null) : + R ...
및
NS_ERROR_UNEXPECTED : 예기치 않은 오류 .../"$ 1")))}} false를 반환; 경우 (u.getParam ("accessibility_focus!"를)) {g.add (i.add (k, "a ...
여기 내 코드를 다시 만들려고했습니다 : http://jsfiddle.net/xc4sz/1/ 100 % 아니지만 적어도 작동하지 않습니다. ;)
텍스트 1에서 텍스트 2로 직접 이동하는 대신 "선택 옵션"을 사용하면 텍스트가 제대로 표시됩니다.
가 나는 아래의 "초기화"부분과 관련이있다 같아요
ko.bindingHandlers.tinymce = {
init: function (element, valueAccessor, allBindingsAccessor, context) {
var options = allBindingsAccessor().tinymceOptions || {};
var modelValue = valueAccessor();
var value = ko.utils.unwrapObservable(valueAccessor());
var el = $(element)
//handle edits made in the editor. Updates after an undo point is reached.
options.setup = function (ed) {
console.log(ed)
ed.onChange.add(function (ed, l) {
if (ko.isWriteableObservable(modelValue)) {
modelValue(l.content);
}
});
};
//handle destroying an editor
ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
setTimeout(function() { $(element).tinymce().remove() }, 0)
});
//$(element).tinymce(options);
setTimeout(function() { $(element).tinymce(options); }, 0);
el.html(value);
},
update: function (element, valueAccessor, allBindingsAccessor, context) {
var $element = $(element),
value = ko.utils.unwrapObservable(valueAccessor()),
id = $element.attr('id');
//handle programmatic updates to the observable
// also makes sure it doesn't update it if it's the same.
// otherwise, it will reload the instance, causing the cursor to jump.
if (id !== undefined) {
var tinymceInstance = tinyMCE.get(id);
if (!tinymceInstance)
return;
var content = tinymceInstance.getContent({ format: 'raw' });
if (content !== value) {
$element.val(value);
//this should be more proper but ctr+c, ctr+v is broken, above need fixing
//tinymceInstance.setContent(value,{ format: 'raw' })
}
}
}
};
좋은 분, michaelpapworth. 텍스트의 태그/자동 태그 추가를 바인딩에 포함시킬 수 있습니까? ;) –
바인딩 컨텍스트 내에서 "태그 지정/자동 태그 지정"이란 무엇을 의미하는지 정확히 모르겠습니다. GitHub의 내 저장소에 대한이 문제를 고려해 주시겠습니까? –