mervick / emojionearea

Emoji Picker Plugin for jQuery
https://jsfiddle.net/mervick/1v03Lqnu/765/
MIT License
953 stars 257 forks source link

Can Anyone help with Emojionearea auto complete API ? #416

Open syahrul223 opened 4 years ago

syahrul223 commented 4 years ago

Im using Emojionearea here, then i want to use autocomplete from API data with POST method here is my code :

function get_account(){
           var form = new FormData();
           form.append('page', 'all');
           $.ajax({
               url : "{{$mentionRoute}}",
               type: "POST",
               contentType:false,
               processData: false,
               data : form,
               headers: {
                   'X-CSRF-Token': '{{csrf_token()}}'
               },
               beforeSend: function(){

               },
               success: function(res){
                console.log(res);
                $("#post-content").emojioneArea({
                    autocomplete: true,
                    events:{
                        ready: function() {
                            this.editor.textcomplete([{
                            id: 'post-content',
                            match: /\B@([\-\d\w]*)$/,
                            search: function(term, callback) {
                                    callback($.map(res, function(mention) {
                                    return mention.indexOf(term) === 0 ? mention : null;
                                }));
                            },
                            template: function(value) {
                                return '<b>' + value + '</b>&nbsp;';
                            },
                            replace: function(value) {
                                return '<b>@' + value + '</b>&nbsp;';
                            },
                            cache: true,
                            index: 1
                            }]);
                        },
                        keydown: function(b,e){
                            var tval=this.getText();
                            set_content_text(tval);
                        },
                        keyup: function(b,e){

                        var tval=this.getText();
                            set_content_text(tval);
                        },
                        emojibtn_click:function(b,e){

                            var tval=this.getText();
                            set_content_text(tval);
                        },

                        paste:function(b,e){
                            var tval=this.getText();
                            set_content_text(tval);
                        }
                    }
                });
               },
               error: function(xhr, status){
                console.log(xhr);
                console.log(status);
               }
           });
       }

but the data didn't show up on the textarea, but the response data is there. what is my mistake ...? anyone can help?