Search code examples
javascriptjqueryasp.nettwitter-bootstrapaddthis

AddThis plugin doesn't work in modal window


My task was to create modal window with content (some details about game) which will be opened on row click (on Search page : 1 row - 1 game). Content i try to get from aspx page. Cause this page are inherited from Master page where all scripts are attached (when i open this modal all scripts were loaded again and this broke page layout) i create second Master page only for this modal window where are included just necessary file, scripts etc.

Problem : everything is fine exept one thing : on Page Searcg.aspx and in modal window i use addThis plugin. On Search page everything is initialized, but when i open modal - addThis plugin doesn't loaded needed icons etc.

How i use plugin :

                    <!-- AddThis Button BEGIN -->
                    <div class="addthis_toolbox addthis_default_style">
                        <a class="addthis_button_facebook"></a>
                        <a class="addthis_button_email"></a>
                        <a class="addthis_button_twitter"></a>
                        <a class="addthis_button_print"></a>
                        <a class="addthis_button_compact"></a>
                        <script type="text/javascript">var addthis_config = { "data_track_clickback": true };</script>
                        <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=username"></script>
                    </div>
                    <!-- AddThis Button END -->

Solution

  • If you're dynamically loading the buttons within the modal window, you'll need to call addthis.init() and/or addthis.toolbox() to render the div. Here's some more information from the AddThis website:

    http://support.addthis.com/customer/portal/articles/1293805-using-addthis-asynchronously