Hey Guys,
I am new to JQuery and I am trying to understand how JQuery selectors work in particular. I am using the Debut theme for my website.
In theme.js under the function _createLineItemList I see something like the code below (line #8 in code dump below)
$(selectors.cartItemTitle, $item)
.text(item.product_title)
.attr(‘href’, item.url);
which I believe targets the below HTML
What does this JQuery selector do in the context of the function. It does not seem to be initialising a variable nor setting the data-attribute.
Below is a dump of the function for some reference
createLineItemList: function(state) {
return $.map(
state.items,
function(item, index) {
var $item = this.$itemTemplate.clone();
var $itemPriceList = this.$itemPriceListTemplate.clone();
this._setLineItemAttributes($item, item, index);
this._setLineItemImage($item, item.featured_image);
$(selectors.cartItemTitle, $item)
.text(item.product_title)
.attr('href', item.url);
var productDetailsList = this._createProductDetailsList(
item.product_has_only_default_variant,
item.options_with_values,
item.properties
);
this._setProductDetailsList($item, productDetailsList);
this._setItemRemove($item, item.title);
$itemPriceList.html(
this._createItemPrice(
item.original_price,
item.final_price,
this.$itemPriceListTemplate
)
);
if (item.unit_price_measurement) {
$itemPriceList.append(
this._createUnitPrice(
item.unit_price,
item.unit_price_measurement,
this.$itemPriceListTemplate
)
);
}
this._setItemPrice($item, $itemPriceList);
var itemDiscountList = this._createItemDiscountList(item);
this._setItemDiscountList($item, itemDiscountList);
this._setQuantityInputs($item, item, index);
var itemLinePrice = this._createItemPrice(
item.original_line_price,
item.final_line_price,
this.$itemLinePriceTemplate
);
this._setItemLinePrice($item, itemLinePrice);
return $item[0];
}.bind(this)
Can someone please throw some light on this.