如何创建动态共享弹出窗口

时间:2016-05-01 10:11:52

标签: javascript php jquery

我有一些帖子可以通过php获取而loop&每个帖子都有一个分享此帖子的链接,例如

Post 1 - share this post
Post 2 - share this post
Post 3 - share this post
there are many more post

我读了一篇jquery文章,我得到了这个 - >

jquery part

$('body').on('click','.js_share',function(){

var post=$(this).parents('.post');

var id=post.attr('data-id');

    confirm(__['Share Post'],__['Are you sure you want to share this post?'],function(){

$.post(api['posts/reaction'],{'do':'share','id':id},function(response){if(response.callback){eval(response.callback);}

else{modal('#modal-success',{title:__['Success'],message:__['This has been shared to your Timeline']});}}).fail(function(){modal('#modal-message',{title:__['Error'],message:__['There is some thing went worng!']});});});});

html Part

<script id="modal-success" type="text/template">
    <div class="modal-body text-center">
        <div class="big-icon success">
            <i class="fa fa-thumbs-o-up fa-3x"></i>
        </div>
        <h4>{{title}}</h4>
        <p class="mt20">{{message}}</p>
    </div>
</script>

以上脚本在控制台中不起作用

我已经添加了__ by

<script type="text/javascript">var __=[];__["Follow"]='Follow';__["Share Post"]='Share Post';__["Remove"]='Remove';__["Error"]='Error';__["Success"]='Success';__["Loading"]='Loading';__["Like"]='Like';__["Unlike"]='Unlike';__["Delete Comment"]='Delete Comment';__["There is some thing went worng!"]='There is some thing went worng!';__["This has been shared to your Timeline"]='This has been shared to your Timeline';</script>

0 个答案:

没有答案