I’m trying to initiate a class depending on two conditions, if the class hasn’t been initiated and if a class to which all the methods are applied is present in the markup :
if (!window.Recipes && !$('#page').find('#recipesSearchResults').length) {
return window.Recipes = new Recipes;
} else {
return true;
}
Is the above statement correct ? Or am I missing something ?
!$('#page').find('#recipesSearchResults').lengthwill returntrueif the length of$('#page').find('#recipesSearchResults')is not0.However,
#recipesSearchResultsis an ID selector, and not a class selector.You should change this to
.recipesSearchResults: