<textarea data-bind="value: Post, event:{keypress: viewModelTrackerViewModelForm.test}" rows="2" maxlength="${MaxValue}" cols="10" id="text_${AssetId}" />
but inside my function I am calling the following to get the highlighted text
function getSelectedText() {
if (window.getSelection) {
return window.getSelection();
}
else if (document.selection) {
return document.selection.createRange().text;
} else if (document.getSelection) {
return document.getSelection();
}
return '';
}
is there a better way to do this
regards
Derek
//get the selected textvar selectedText = '';
if (window.getSelection) {selectedText = window.getSelection();
} else if (document.getSelection) {
selectedText = document.getSelection();
} else if (document.selection) {
selectedText = document.selection.createRange().text;
}
It looks like there may be some alternatives if you are limiting it to an input/textarea, but it looks like it would be a lot more code.
<div class="TrackerLinkList" >
Time: <input type="text" data-bind="value: Time" id="time_${AssetId}"/>
<a href="#" data-bind="click: function() { viewModelTrackerViewModelForm.editPost($data) }"> <img src="<%= ResolveUrl("~") %>/Content/Images/ext/default/dd/save.png" alt="Save" /></a>
<a href="#" data-bind="click: function() { viewModelTrackerViewModelForm.deletePost($data) }"> <img src="<%= ResolveUrl("~") %>/Content/Images/ext/default/dd/delete.gif" alt="Delete" /></a>
On Hold: <input type="checkbox" id="onhold_${AssetId}" data-bind="checked: IsOnHold" />
Icon: <select id="icon_${AssetId}" data-bind="options: viewModelTrackerViewModelForm.icons, value: Icon"></select>
<div class="EditorContainer">
<div class="EditorInnerContainer story">
<textarea data-bind="value: Post, event:{keypress: viewModelTrackerViewModelForm.test}" rows="2" maxlength="${MaxValue}" cols="10" id="text_${AssetId}" />
</div>
</div>
</div>
I want the user to have the ability to highlight a word in the text and make it bold, italic or underline - is there any neat way to do this with native knockout
[1]: http://tinymce.moxiecode.com/
--
-barkmadley
sent from an internet enabled device
http://barkmadley.com
<textarea data-bind="value: Post, event:{keypress: function(event) {viewModelTrackerViewModelForm.test(event,$data)} }" rows="2" maxlength="${MaxValue}" cols="10" id="text_${AssetId}" />
test: function (event, item) { if (event.ctrlKey) { wrap_selection("text_" + ko.toJS(item).AssetId, '<b>', '</b>', 0, 0); } else { return true; } }