Ad

Simple Javascript Not Working In Shopify

- 1 answer

I give up, I can't get this to work even though in the Shopify documentation it says it should. I just need to turn off the loading spinner.

Here is my javascript

<script type="text/javascript">
  ShopifyApp.ready(function(){
  ShopifyApp.Bar.loadingOff();
  });
</script>

And then this is the documentation from Shopify:

ShopifyApp.Bar.loadingOff()

Stops the loading spinner. Should probably be called on every page in ShopifyApp.ready().

There is nothing in the application.html.erb file or the embedded_app.html.erb file that would override this..

I found other people with the same issue.

Any idea what I'm doing wrong?

Ad

Answer

I think you're missing a key debugging check. Check your console, specifically the console logs for the embedded App iframe. I bet you'll find one of two things.

  1. you made a JS error and therefore that code is not running (the code you pasted is correct and does work)

  2. there is another process not working, like a connection to a network resource (websocket??)

Anytime some Shopify embedded App code borks, you might see the loading bar go slowly and forever. These events are usually short-lived.

My guess is, you have a JS error in your code, so as soon as you fix that, your loading bar issues will disappear.

Ad
source: stackoverflow.com
Ad