티스토리 뷰

$.fn.mention = function(param, callback){
    // JSON 은 '아이디|이름|소속'으로 구성됨
    var url = [주소];
    var __this = this;
    $.getJSON(url, function(jdata){
        $(__this).textcomplete([
            {
                mentions: jdata.data,
                match : /\B@([\.\w]*)$/,
                search: function (term, callback) {
                    callback($.map(this.mentions, function (mention) {
                        if(mention.indexOf(term) === 0){
                            var arryMention = mention.split('|');
                            return arryMention[0] + '<br>' + '(' + arryMention[1] + '), ' + arryMention[2];
                        }else{
                            null;
                        }
                    }));
                },
                index: 1,
                replace: function (mention) {
                    var arryMention = mention.split('<br>');
                    return '@' + arryMention[0] + ' ';
                }
            }
        ]);
    });
};
 
// 사용할 때
$('input[type=text], textarea').mention();


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함