程序化保存按钮不起作用 [英] Programmatic Save button not working
问题描述
我正在一个网站上工作,该网站每页将有多个保存"按钮,并且每个页面都需要一个回调,以便可以在自己的系统中注册用户已完成保存"操作.我以为我已经想出了如何以编程方式进行操作...但是,对于我创建的每个小部件,当我尝试通过SDK将其添加到DOM时,都会出现无法读取属性'style'null'的错误"错误. /p>
这是我的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);
})();
基本上,在加载SDK时,我会仔细检查并找到所有包含场所ID的隐藏输入,然后在此处尝试创建一个保存"小部件来替换我拥有的空锚标签持有者.
这是Chrome控制台中错误屏幕截图的链接:
http://gyazo.com/f011c25bb88181251e2820e748b41093.png
任何帮助将不胜感激.谢谢.
这是我正在使用的Foursquare文档: https://developer.foursquare.com/overview/widgets#programmatic-instantiation
很远,但是您是否更改了Array对象的原型?
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
A long shot, but did you change the prototype of the Array object ?
这篇关于程序化保存按钮不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!