Note that there are some explanatory texts on larger screens.

plurals
  1. POonclick help - reading the value of a specific class
    primarykey
    data
    text
    <p>I hope my description will not be too confusing! I am trying to integrate a javascript shopping cart, simplecart-js, into a Jquery LightBox, Yoxview. Yoxview has an option to add button links in the popup title pane for various options, downloading, shopping cart, etc. The relevant code for the shopping cart button is:</p> <pre><code>var yoxviewCartButton = $("&lt;a&gt;", { title: "Add to cart", href: "javascript:;", onclick:"simpleCart.add('name=Awesome', 'price=14.95','quantity=1');" }); yoxviewCartButton.append($("&lt;img&gt;", { src: "yoxview/images/yoxview_cart_icon.png", alt: "Add to cart", css: { width: 18, height: 18 }, })); </code></pre> <p>the specific integration for shopingcart-js into the button is:</p> <pre><code>href: "javascript:;", onclick:"simpleCart.add('name=Awesome', 'price=14.95','quantity=1'); </code></pre> <p>the html structure I'm using is:</p> <pre><code>&lt;a class="item yoxview simpleCart_shelfItem" href="pics/pic0.png" title="Test1"&gt; &lt;img class="content" src="pics/pic0.png" title="Test1"/&gt; &lt;span class="caption item_name"&gt;Pic 0 &lt;span class="item_price"&gt;$14.99&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; </code></pre> <p>The onclick event works but inputs the same info for each image, obviously, so I am trying to get the "item_name" and "item_price" for each "simpleCart_shelfItem" to input into the name= and price= field of the onclick event. I'm not sure how to get jquery to input these values. Any help or direction would be greatly appreciated. </p> <p>BTW, Before I tried butchering this code, the original code was set to show an alert:</p> <pre><code> var yoxviewCartButton = $("&lt;a&gt;", { title: "Add to cart", href: "#", click: function(e){ e.preventDefault(); alert("The image \"" + $(this).data("yoxview_cart") + "\" can be added to cart through AJAX."); } }); yoxviewCartButton.append($("&lt;img&gt;", { src: "../images/yoxview_cart_icon.png", alt: "Add to cart", css: { width: 18, height: 18 } })); $(".yoxview").yoxview({ infoButtons: { download: yoxviewDownloadButton, cart: yoxviewCartButton }, onSelect: function(i, image) { $.yoxview.infoButtons.download.attr("href", image.media.src); $.yoxview.infoButtons.cart.data("yoxview_cart", image.media.src); } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload