sqwidget icon indicating copy to clipboard operation
sqwidget copied to clipboard

Non-deterministic behavior when including widget twice on same page

Open lrettig opened this issue 9 years ago • 6 comments

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

lrettig avatar Jul 23 '15 19:07 lrettig

Any progress on solving this problem?

mtree avatar Sep 21 '15 07:09 mtree

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.

lrettig avatar Sep 21 '15 16:09 lrettig

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.

premasagar avatar Sep 21 '15 16:09 premasagar

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!

lrettig avatar Oct 10 '15 20:10 lrettig

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".

premasagar avatar Oct 12 '15 09:10 premasagar

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!

lrettig avatar Nov 14 '15 18:11 lrettig