여기, 컨트롤의 ID, 관찰 및 위치 지정자 텍스트 부하에
self.PlaceholderOptions =
{
CustomerInfoAccountBackground: ['#custInfoAccountBackground', self.AccountPlanVM.AccountPlan.AccountBackground, "<div style=\"" + self.PlaceholderStyle + "\">" + 'Placeholder Example Text' + "</div>"]
};
와 변수 옵션을 만들기보기 모델에서 내 구현 솔루션
텍스트 영역
<textarea id="custInfoPriorPerformance" rows="10" cols="20" data-bind="kendoEditor: { value: AccountPlanVM.AccountPlan.PriorYearSummary }" > </textarea>
의 I 편집기 상자의 초점/흐림에 바인딩합니다. 그리고 양식을 게시하기 전에, 나는 관찰 대상에서 자리 표시 자 텍스트를 삭제합니다.
//Editor Placeholder methods
self.BindEditorPlaceholders = function() {
for (var propt in self.PlaceholderOptions) {
//Options array
var options = self.PlaceholderOptions[propt];
// get a reference to the Editor
var editor = $(options[0]).data("kendoEditor");
//Currently saved value
var currentValue = options[1]();
//If we don't have any text saved, inject placeholder
if (!currentValue) {
editor.value(options[2]);
}
//Attach Events to Editor Iframe
$(options[0]).siblings(".k-content").focus(options, self.EditorFocus);
$(options[0]).siblings(".k-content").blur(options, self.EditorBlur);
}
};
self.EditorFocus = function(e) {
//Options array
var options = e.data;
// get a reference to the Editor
var editor = $(options[0]).data("kendoEditor");
//Current editor value
var htmlValue = editor.value();
if (htmlValue == options[2]) {
//Clear editor value
editor.value('');
}
};
self.EditorBlur = function (e) {
//Options array
var options = e.data;
// get a reference to the Editor
var editor = $(options[0]).data("kendoEditor");
//Current editor value
var htmlValue = editor.value();
if (htmlValue == '') {
//Set editor value back to placeholder
editor.value(options[2]);
}
};
self.CleanEditorPlaceholders = function() {
for (var propt in self.PlaceholderOptions) {
//Options array
var options = self.PlaceholderOptions[propt];
// get a reference to the Editor
var editor = $(options[0]).data("kendoEditor");
//Currently saved value
var currentValue = options[1]();
//If the current text is the placeholder, wipe it out
if (currentValue == options[2]) {
options[1]('');
}
}
};