sqwidget
sqwidget copied to clipboard
Non-deterministic behavior when including widget twice on same page
Hi Prem
Thanks for creating a really awesome tool. I've used sqwidget to create a set of widgets that are displayed on third party blogs (you can see one at the top left of www.amothershipdown.com). I've run into an issue when I try to include the same widget twice in the same page.
Basically, I sometimes get this error, sometimes not:
Uncaught TypeError: Cannot read property 'addMethod' of undefined
Which appears to be coming from jQuery and may indicate a namespace conflict?
Based on comments in your code it looks like loading the same code twice isn't currently supported. I also tried copying the code and loading it a second time from a second URL, which also didn't work.
Is there any way to display two sqwidgets on the same page?
Thanks
Any progress on solving this problem?
None. I'm sure the nondeterministic nature of the problem has to do with the (random) order that the scripts are loaded. As far as I can tell, sqwidget does not support multiple widgets on the same page.
Thanks for this issue and apologies for the non-reply. I don't see the issue on the link you provided, presumably because the document has changed. Are you able to provide a stripped down version of the issue?
Sqwidget should support multiple versions of a widget.
I should say, the library is not under active development at the moment. It may get my attention in future; for the meantime, pull requests and additional maintainers are welcome.
Hi @premasagar, I appreciate the response.
You can find the sqwidget in question here: http://widget.healthierapp.com/index-multi.html
If you glance at the HTML, you can see that I attempted to include the same widget twice, but it only appears once. Please let me know if I've missed something obvious.
Thanks!
Hello @lrettig. In the browser consoles, Chrome says Uncaught TypeError: Cannot read property 'addMethod' of undefined healthier.js:formatted:14770
and Firefox TypeError: jQuery.validator is undefined healthier.js:10
.
It is a little difficult to tell from the minified code. It would be a good idea to strip it down to the smallest parts that fail. The jQuery.validator
seems to originate from "jquery-additional/additional-methods"
.
Hi @premasagar, sorry again for the slow response. Also sorry about the minified code. I uploaded a non-minified version of my code, at the above URL and here: http://widget.healthierapp.com/dist/healthier.js
Yes, this is the same error I see in Chrome.
I don't have time to troubleshoot this further right now but I'm happy to be helpful if I can be, please let me know.
Thanks!