2017-01-23 72 views
0

我在我的网站上整合了“Embed Layout”彗星聊天功能。现在我想在页面加载时打开特定的朋友聊天。在cometchat中加载“好友列表”后是否有任何回调函数?

在文档中,我发现下面的代码也是这样做的。 REF:Documentation Link

jqcc.cometchat.chatWith(user_id)

我已经包含在从管理面板自定义的JS。但是,它显示在下面的错误控制台

jqcc.cometchat.chatWith is not a function

但如果我之后,从它做工精细控制台加载好友列表中使用相同的。

我该如何解决这个问题?

+0

@Xufox误差jqcc.cometchat.charWith是不是一个函数 – Rajasekhar

+0

'charWith'?或者'chatWith'?请[编辑]你的问题并提供[最小,完整和可验证的示例](http://stackoverflow.com/help/mcve)。这应该工作。 – Xufox

+0

这是chatWith @Xufox – Rajasekhar

回答

0

目前用于暂时我已经在添加下面的代码修复了这个问题自定义JS

var first_chat_loaded = false; 
var first_chat = setInterval(function() { 
    try { 
     if (first_chat_loaded === false) { 
      // Function to get other user id defined in parent html page 
      var other_userid = parent.get_other_user_id(); 
      jqcc.cometchat.chatWith(other_userid); 
      first_chat_loaded = true; 
      clear_first_load(); 
     } 
    } catch (e) { 

    } 
}, 1000); 

function clear_first_load() { 
    clearInterval(first_chat); 
} 

请让我知道,如果做同样的任何适当的方式。

0

请使用此代码段对上述问题

var checkfn = setInterval(
    function(){ 
     if(typeof jqcc.cometchat.chatWith == 'function'){ 
      jqcc.cometchat.chatWith(user_id); 
      clearInterval(checkfn); 
     } 
    }, 
500); 
相关问题