Programmatic Save button not working

南笙酒味 提交于 2019-12-24 17:53:36

问题


I'm working on a site that will have more than one 'Save' button per page, and I need a callback for each one so that I can register in my own system that the user has completed the Save action. I thought I had figured out how to do this programmatically... but for each widget I create, when I try to add it to the DOM through the SDK, I get a "Cannot read property 'style' of null" error.

Here's my Javascript

<script type='text/javascript'>
    (function () {
        window.___fourSq = {
            "uid": "31904528",
            "secure": true,
            "explicit": false,
            "onReady": function () {
                $('.fourSquareVenueId').each(function () {
                    var vid = $(this).val();
                    var widget = new fourSq.widget.SaveTo({
                        "vid": vid
                    });
                    var container = $(this).parent().find('.placeholder');
                    widget.replace(container);
                });
            }
        };
        var s = document.createElement('script');
        s.type = 'text/javascript';
        s.src = 'https://platform-s.foursquare.com/js/widgets.js';
        s.async = true;
        var ph = document.getElementsByTagName('script')[0];
        ph.parentNode.insertBefore(s, ph);
    })();

Basically, when the SDK is loaded, I go through and find all of my hidden inputs with the venue id in it, and there I try to create a 'Save' widget to replace an empty anchor tag I have as a place holder.

And here's a link to the screenshot of the error in the Chrome console:

http://gyazo.com/f011c25bb88181251e2820e748b41093.png

Any help would be greatly appreciated. Thanks.

EDIT: Here's the Foursquare documentation i'm using: https://developer.foursquare.com/overview/widgets#programmatic-instantiation


回答1:


A long shot, but did you change the prototype of the Array object ?



来源:https://stackoverflow.com/questions/11401832/programmatic-save-button-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!