English 中文(简体)
Why does an AddThis widget not work if included inside a jQuery modal dialog?
原标题:

If included anywhere else on the page, an AddThis bookmarking widget will work fine.

But on a jQuery modal dialog, no popup appears.

Is that because it would require another modal dialog within a modal dialog?

How to work around this?

<div id="dialog-modal" title="Modal dialog with AddThis">
    <!-- AddThis Button BEGIN -->
    <div class="addthis_toolbox addthis_default_style ">
    <a href="http://www.addthis.com/bookmark.php" class="addthis_button_compact">Share</a>
    <span class="addthis_separator">|</span>
    <a class="addthis_button_preferred_1"></a>
    <a class="addthis_button_preferred_2"></a>
    <a class="addthis_button_preferred_3"></a>
    <a class="addthis_button_preferred_4"></a>
    </div>
    <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
    <!-- AddThis Button END -->
</div>

<script>
$(function() {

    $( "#dialog-modal" ).dialog({
        height: 140,
        modal: true
    });
});
</script>
问题回答

You can use AddThis JavaScript API to render buttons or toolboxes. Reference: http://www.addthis.com/help/client-api#rendering-js

To this problem I have found two solutions. The first is to use getScript, to reload the addthis js script everytime the modal dialog (or another div) is opened, but this will create extra loading. The other solution is to simply not to let any of the divs containing the addthis code be hidden at any time (i.e. display:none), but instead hide it from the screen with .animate({marginTop: -200px }, 0);, .css or another method with a similar result (and of course give the html, body or a containing div a css attribute with overflow:hidden).





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签