Syndicate

Feed

Using the jQuery library

I will be using the jQuery library in this tutorial, but you should use any JavaScript library you know well. Work with what you know and love. If you don't really know any library, I strongly recommend using jQuery because it is easy to learn and light-weight. The latest release of jQuery on this day (August 28th, 2008) is 1.2.6. But go ahead and download the latest release, whichever 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 an other 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 use the jQuery object.

{{ '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. And then you can write jQuery code in any template without conflict. Of course, you will have to leave the $ alias alone! Unless you write code to be understood by another library that makes use of the alias. For the full, technical explanation, head over here.

We are now ready to implement our JavaScript solution. But first, we'll write XHTML to add two drop-down select elements to the Add to Cart form in our product template.

Last edited by Caroline Schnapp about 13 years ago.

Comments

The crest condo

The Crest @ Prince Charles Crescent is a brand new residential development from a joint venture led by Wing Tai Holdings, Metro Australia Holdings & Maxdin Pte Ltd. The Crest is located in the tranquil Jervois precinct which fronts the Good Class Bungalows of both Chatsworth and Bishopsgate estates. Sitting on a land parcel of over 256,000 sqft will be of superior spatial quality and the envy of many with the beautiful architecture designed by renowned architect, Toyo Ito & Associates.

Toyo Ito is a Japanese architect known for creating conceptual architecture and has been named “One of the world’s most innovative and influential architects”. The Crest will be a nuanced interplay of proportion and space, designed with a fine eye for detail which Wing Tai is reputed for in the 50 years of living heritage.
www.thecrest-condo.com

Clermont Residences

CLERMONT RESIDENCE, TALLEST RESIDENCES IN THE HEART OF SINGAPORE CITY

As the part of the mega project Tanjong Pagar Centre, Clermont Residence rises as the iconic development of Tanjong Pagar Skyline. The condominium offers prestigious and limited collection homes above GuocoTower. Set to be the tallest residences in Singapore, Clermont Residence only starts at 180 metres(equivalent to 50 residential storeys) and reaching up to 290 metres, offering unparalleled sea and city views.
http://www.clermont-residence.net/p/about-clermont-residence.html