Syndicate

Feed

Using the jQuery library

I will be using the jQuery library in this tutorial, but use any JavaScript library you know and love. If you don't know any library, I strongly recommend picking jQuery because it is easy to learn and very light-weight. The latest release of jQuery on this day (September 26th, 2008) is 1.2.6. But go ahead and download the latest release, whatever it is at the time you read this.

You will need to upload the library to your Shopify theme Assets directory.

Once you've done this, you will be able to link to it from your theme.liquid template, by adding the Liquid Output {{ 'jquery-1.2.6.min.js' | asset_url | script_tag }} to the head element of your XHTML document, like so:

<head>
...
{{ 'jquery-1.2.6.min.js' | asset_url | script_tag }}
...
</head>

Your theme may already use another library like Prototype or Mootools. That's not a problem, as you can force jQuery to play nice with other JavaScript libraries. To make it play nice, all you need to do is add one line of JavaScript code in your theme.liquid template, and then use the jQuery namespace whenever you'll write jQuery code.

{{ 'jquery-1.2.6.min.js' | asset_url | script_tag }}
<script type="text/javascript"> 
  jQuery.noConflict();
</script>

This effectively gives the use of the alias $ back to JavaScript libraries that make use of it. For the full, technical explanation, head over here.

In addition to using the jQuery library, we will use one jQuery plugin to aid in the creation of our select boxes. Mind you, this can all be done 'by hand' but let's make our job as easy as possible. Go ahead and download the Select box manipulation plugin. Pick the packed version, its weight is only 2.9 KBytes. The documentation for the plugin is on this page.

To use this plugin, upload it to your Assets directory, and link to it in your theme.liquid template.

{{ 'jquery-1.2.6.min.js' | asset_url | script_tag }}
{{ 'jquery.selectboxes.pack.js' | asset_url | script_tag }}
<script type="text/javascript"> 
  jQuery.noConflict();
</script>

We are now ready to implement our JavaScript solution.

Last edited by Caroline Schnapp about 8 years ago.

Comments

Great and impressive blog!

Great and impressive blog and posts you have. Many weblogs like yours cover subjects that can’t be found in print. Of course you have been carrying out a superb job.
Makrana Marble | Marble Flooring

Your theme may already use

Your theme may already use another library like Prototype or Mootools. That's not a problem, as you can force jQuery to play nice with other JavaScript libraries. To make it play nice, all you need to do is add one line of JavaScript code in your theme.liquid template, and then use the jQuery namespace whenever you'll write jQuery code.
http://e-papierossy.com.pl/en/e-papierosy/102-e-papierosy-zerok-z231211.html
http://e-papierossy.com.pl/en/e-papierosy/101-e-papierosy-zerok-z22121.html
http://e-papierossy.com.pl/en/e-papierosy/76-e-papierosy-gombit-423456.html
http://e-papierossy.com.pl/en/e-papierosy/80-e-papierosy-gambit-123445.htmlhttp://e-papierossy.com.pl/en/e-papierosy/99-e-papierosy-gambit-1221.html

Using JQuery libraries

A good little tutorial on the always relevant Jquery library/plugins. I am learning but must admit that I still find it hard to figure out how to actually get all the relevant information encoded for an 'object' so it can be manipulated by the JQuery functionalities. Suppose that I will just have to play around with the coding a bit more - but your tutorial is helpful nevertheless. So, thank you very much for sharing and for making the seemingly very difficult easier to comprehend.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <css> <html> <javascript> <mysql> <php> <span> <a> <b> <i> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <sup> <sub> <dd> <del> <blockquote> <img> <q> <p> <div>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <css>, <html>, <javascript>, <mysql>, <php>, <rails>, <ruby>.

More information about formatting options

CAPTCHA
I have to wonder if you're a human spammer or a machine, or less likely someone who cares to leave his or her thoughts behind.