[英]Rich text box like facebook comment box
I'm currently working on http://flickogram.com . 我目前在http://flickogram.com上工作。
I need to put rich comment textbox like facebook has. 我需要像Facebook一样放置丰富的评论文本框。
Currently, I've developed a jquery plugin and you can find its working on http://jsfiddle.net/mike_ivanenko/k6zH6/3/ 目前,我已经开发了一个jQuery插件,您可以在http://jsfiddle.net/mike_ivanenko/k6zH6/3/上找到其插件
You can use the plugin as following. 您可以按以下方式使用插件。
$(document).ready(function() {
$('#ttt').richtextbox( {
highlights: [
{char:'#', class:'highlighted', markup: 'topic'},
{char:'@', class:'highlighted', markup: 'people'}
]
,change:function(richtextfield, input) {
$('#output').val(input.val());
}
}
);
});
It works pretty well for putting topic by typing hash(#), but I can't find a way to deal with people's name by typing @. 通过键入hash(#)来放置主题,效果很好,但是我找不到通过@处理姓名的方法。
My intention is as followings. 我的意图如下。
When user types @, drop-down box with search text field will be shown just below the current textbox and user can search for the name. 当用户键入@时,带有搜索文本字段的下拉框将显示在当前文本框的正下方,用户可以搜索名称。
Then the result will be shown in the dropdown, and on clicking the item will be entered in the main text field. 然后结果将显示在下拉列表中,单击后将在主文本字段中输入该项目。 But it should be non-editable.
但是它应该是不可编辑的。 Deleting by [Delete] or [Backspace] key is available.
可用[删除]或[退格]键删除。
Any suggestions? 有什么建议么?
Or please help me out this on github.com/mike-ivanenko/richtextbox 或者请在github.com/mike-ivanenko/richtextbox上帮助我
Thank you 谢谢
Mike 麦克风
you should check out html5's contenteditable
feature 您应该查看html5的
contenteditable
功能
here's what you need http://jsfiddle.net/ZQSHT/2/ 这是您需要的内容http://jsfiddle.net/ZQSHT/2/
$('div').keyup(function(){
var test = $(this).text();
if( test.indexOf('@') >= 0){
// Found world
alert('@');
$('input').focus();
}
});
$('input').change(function(){
alert( $('input').val() );
$('div').append('<a href="http://www.mysite.com/profiles/#">@'+$('input').val()+'</a>');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.