LinkedIn API:动态UI组件 [英] LinkedIn API: Dynamic UI Component

查看:72
本文介绍了LinkedIn API:动态UI组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用从Linkedin搜索结果中获取的公共网址动态填充data-id字段。假设我能够返回公共个人资料网址。如果我直接在页面上放置相同的脚本(不是通过javascript),它就可以工作。

I am trying to dynamically populate the data-id field with a public url fetched from linkedin search results. Assume that I am able to return the public profile url. If I put the same script directly on the page (not through javascript) it works.

resultsHtml += '<script type="IN/MemberProfile" data-id="'+currResult.publicProfileUrl+'" data-format="inline"/>'; 
$("#search-results").html(resultsHtml);

供参考

http://developer.linkedin.com/docs/DOC-1278

推荐答案

如果您正在使用jQuery,我假设您是第一个js文件:
http ://platform.linkedin.com/in.js

if you are using jQuery which i am assuming you are, you 1st need to run that 1st js file: http://platform.linkedin.com/in.js

因此请确保您拥有:

<script src="http://platform.linkedin.com/in.js" type="text/javascript"></script>

在doc的头部。

然后在你打电话的时候在身体里:

and then in the body when u call it:

$(function(){

   ...
   //here is the hack:
   resultsHtml += '<sc'+'ript type="IN/MemberProfile" data-id="'+currResult.publicProfileUrl+'" data-format="inline"></sc'+'ript>';
   //remember to close script tags 

   $("#search-results").html(resultsHtml);

   ...

})

或者你可以试试这个:

$(function(){

   ...

   var $script = $('<script>',{
                    'data-format': 'inline',
                    type: 'IN/MemberProfile',
                    'data-id': "'+currResult.publicProfileUrl+'"
                  })

   $("#search-results").html(resultsHtml);
   $("#search-results").append($script);
   ...

})

这篇关于LinkedIn API:动态UI组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆