/    Sign up×
Community /Pin to ProfileBookmark

Java Script – need help

Hello
i am working on a project where i have some products that i can sort by low to high price and low to high area the template i have, already have a low to high sorting. but have no sense on javascript so do not know how to make a high to low sort

JavaScript:

function initIsotope()
{

if($(‘.listings_container’).length)
{
var grid = $(‘.listings_container’);
grid.isotope(
{
itemSelector:’.listing_box’,
layoutMode: ‘fitRows’,
getSortData:
{

price: function(itemElement)
{
var priceEle = $(itemElement).find(‘.listing_price’).text().replace( ‘$’, ” );
priceEle = priceEle.replace(/s/g, ”);
return parseFloat(priceEle);
},
area: function(itemElement)
{
var propertyArea = $(itemElement).find(‘.property_area span’).text().replace(‘ sq ft’, ”);
console.log(propertyArea);
return parseFloat(propertyArea);
}
}
});

var sortingButtons = $(‘.sorting_button’);

sortingButtons.each(function()
{
$(this).on(‘click’, function()
{
var parent = $(this).parent().parent().find(‘span’);
parent.text($(this).text());
var option = $(this).attr(‘data-isotope-option’);
option = JSON.parse( option );
grid.isotope( option );
});
});
}
}

HTML:

<div class=”sorting_container”>
<div class=”sort”>
<span>Sort By</span>
<ul>
<li class=”sorting_button” data-isotope-option='{ “sortBy”: “original-order” }’>default</li>
<li class=”sorting_button” data-isotope-option='{ “sortBy”: “price” }’>price</li>
<li class=”sorting_button” data-isotope-option='{ “sortBy”: “area” }’>area</li>
</ul>
</div>
</div>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 23.2019 — [[58],[2,4]]
×

Success!

Help @detvedjegikkeDK spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...