我在Github上使用jQuery Preview Plugin进行链接预览。当我在输入中输入或粘贴URL时它可以顺利运行,但是当页面加载/刷新时,是否可以从数据库加载链接?我尝试了下面的jQuery代码,但它无法正常工作。我在angularjs中使用它。这是我的标记。
<div class="post-feeds-block" data-ng-init="init()" >
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true" >
<div class="panel panel-default" ng-repeat="feeds in postfeeds">
<div id="collapse{{feeds.p_id}}" class="panel-collapse collapse" ng-class="{in: feeds.expanded}" role="tabpanel" aria-labelledby="heading{{feeds.p_id}}">
<div class="panel-body">
<p data-ng-bind-html-unsafe="feeds.description" id="content{{feeds.p_id}}"></p>
<!-- Links section -->
<div class="attached-feeds" ng-show="feeds.weblink">
<div>
<a href="{{feeds.weblink}}" id="weblink-{{feeds.p_id}}" class="weblink"></a>
<input class="url_load" type="text" value="{{feeds.weblink}}" style="display:none;"/>
<div class="selector-wrapper" id="{{feeds.p_id}}"></div>
</div>
<span class="title-icon">
<span></span>
<a class="edit" href="javascript:void(0);"></a>
<span></span>
<a class="delete" href="javascript:void(0);"></a>
<span></span>
<a class="drag" href="javascript:void(0);"></a>
</span>
</div>
<!-- Links section -->
</div>
</div>
</div>
</div>
</div>
/* Javascript */
window.onload = function(){
setTimeout(loadPreview(), 1000);
}
function loadPreview(){
$(".url_load").each(function(){
$(this).preview({
key:'xxxxxxxxxxxxxxxx',
render: function(obj){
$(this).parent().find('.selector-wrapper').html(obj);
}
});
});
};
任何人都可以帮我吗?