For those who use or have used THIS code, please tell me how to get a boolean
value from the exists
function. It returns an object, and I can't find any boolean
values inside it.
Asked
Active
Viewed 350 times
-1

chrisfrancis27
- 4,516
- 1
- 24
- 32

AndreiBogdan
- 10,858
- 13
- 58
- 106
2 Answers
1
Never used this, but found this within a single click.
searching keys is annoying and tedious. gawd! but wait...
// test for existence of a key
lawnchair(function(){
this.exists('my-key-name', function(exists) {
console.log(exists)
})
})
What does that print into your console? Removing the string should help debug the issue.
EDIT - After digging around, there are two definitions for the exists
function.
exists: function (key, cb) {
this.lambda(cb).call(this, !!(store[key]))
return this
}
And
exists: function (key, cb) {
var exists = this.indexer.find(this.name+'.'+key) === false ? false : true ;
this.lambda(cb).call(this, exists);
return this;
}
They both should return boolean values. The first one might be a bit suspicious. Not sure. Try including the expanded JS version with the comments and breakpoint in the Lawnchair functions. You'll find what's going on in no time.
Sleep time here :) Good luck.

Aesthete
- 18,622
- 6
- 36
- 45
-
Ha! Same answer, same time. "Read the documentation!" :) – chrisfrancis27 Sep 10 '12 at 12:58
-
It displays "existente is: " [object Object]. Looked inside the object, no boolean values. – AndreiBogdan Sep 10 '12 at 12:58
-
@AndreiBogdan - Is that for something that exists? Are you sure it returns anything if not found? – Aesthete Sep 10 '12 at 12:59
-
Pro tip: If you want to log strings and objects (or other values) in the same statement, separate them with a comma instead of concatenating - that way you can still expand and inspect them in the console. – chrisfrancis27 Sep 10 '12 at 13:00
-
yeah, it exists, I've checked and rechecked. I've just found the link below, in which it says that the code is bugged and he got it from github. Now can anyone tell me, how exactly I get the code from github ? There are a bunch of files in there ... which one do i get? http://stackoverflow.com/questions/9862892/lawnchair-exists-method – AndreiBogdan Sep 10 '12 at 13:01
-
The github source is [here](https://github.com/brianleroux/lawnchair/tree/master/src) - you probably only need the `Lawnchair.js` file but grab anything else you need too. – chrisfrancis27 Sep 10 '12 at 13:03
-
It says `adapter missing` when i use only that file. I've added the dom.js content to it as well, no more `adapter missing` error but it still displays an object instead of a boolean value. – AndreiBogdan Sep 10 '12 at 13:04
-
I had a bit of a look through the source, see my changes. It still doesn't answer the question but might help you on your way. – Aesthete Sep 10 '12 at 13:08
1
Never used it, but the documentation suggests that your callback function to exists
will receive a boolean argument:
// test for existence of a key
lawnchair(function(){
this.exists('my-key-name', function(exists) {
console.log('existence is: ' + exists)
})
})

chrisfrancis27
- 4,516
- 1
- 24
- 32