last day (26 days later) » 

11:03 PM
hello
is it okay for me to ask you my question?
 
Yeah
We can talk about it in TNB
 
I have this page, a gellery with filters
filters work okay
if you filter, open a doc and return the filtered state is still there, great
my problem is with the searchbox
the searchbox should work the filter function
 
they are both small functions dealing with the same data
seems to me they shpould be able to play well
I gathered codes from different places
search box works a little witrh each key stroke
 
The search box should only return results that also fit the filter?
 
11:06 PM
actually filtering doc titles
the search box should.. yes, plus some more key terms if thats possible
 
Hang on so what doesn't work?
 
the search box
the filter function stores the filtered state in sessionstorage
 
ok can you send me the code?
 
the search box is not tied to that at all
in here okay?
 
11:07 PM
this is the search box code:
<script>
//Library Search Box filter results based on query
function filterBox(selector, query) {
query = $.trim(query); //trim white space
query = query.replace(/ /gi, '|'); //add OR for regex query
$(selector).each(function () {
($(this).text().search(new RegExp(query, "i")) < 0) ? $(this).hide().removeClass('hidden') : $(this).show().addClass('visible');
});
}

//Library Search Box Results Applied as Filter
$('#searcher').keyup(function (event) {
//if esc is pressed or nothing is entered
if (event.keyCode == 27 || $(this).val() == '') {
 
ok so hit edit then Ctrl+K
Then save it
 
? hot edit on where?
 
on your message with the code
 
it brought up a prompt
 
Nvm I found the code on JS fiddle
 
11:09 PM
"this is the searchbox code"
thanks yes its there
 
Ok I think I found the issue
 
!!!
this is the function that works, does the filtering:
 
I know theres some variable name problems
 
The search is overriding the filter
 
11:11 PM
aah
 
Basically you are filtering then giving all results matching the search
I am going to try and edit a bit of code real quick
@Webster here:
 
Is that a link?
 
Try it out
I tested with the search: ce
It gave 2-3 results
Then I clicked the filter combustible gasses
It filtered the results
@Webster
 
hmm, i placed the new script on my page
hard for me to see a difference
 
11:19 PM
let me put it up on the live site
 
Good plan
Tell me when
 
okay here
when you start to write "coal" in the search box all results except "c things dissappear"
but they don't fill the space
and if you hit enter the results go away
 
I know why
@Webster fixing it
Are you allowed to put a comment in for me in the code?
 
sure
 
11:27 PM
I changed function filter to filterBox to avoid conflict
 
@Webster can you send me a jsfiddle with updated code?
I may have found the final problem
 
oaky
 
But I can't be sure until I get the latest version
 
11:30 PM
unfortuinately the fiddle display box is not great
 
the url is ewebster
 
cant actually see filter results
too far down
 
thats your code in there
go back 2 versions to see it before changes
 
ok
@Webster wow this is stubborn
 
11:40 PM
is it possible that search is using visibility and filter is using show/hide?
 
I know the issue
Just can't get it to work
 
if seach box waited for all characters to be entered, then press button or hit enter and load that term into filter that might work
 
Well the issue is on enter it notices that you pressed a key and the input is blank so it wipes the search
 
that key by key functionality is cool but not neccessary
I'm super grateful for help
 
Ok to fix the issue you have to make sure that you do not clear the search bar on hitting enter
 
11:43 PM
this has been tying me up in knots
and my job ison the line
 
Yeah i get that
So in the line you clear the search results, just make sure that it is not the keyCode 13
 
on submit...
 
Lines 5-11
Since enter is counted as a key press and it gives no text as output it just clears the search bar
 
so this
if (event.keyCode == 27 || $(this).val() == '') {
may become
if (event.keyCode == 13 || $(this).val() == 'TheValue') {
 
11:45 PM
or if keycode 13 then do next thing
 
I may have a huge fix
Nope
 
I'm good, take your time
 
Hey why don't we just remove the enter/submit button all together?
With live search there is no reason to have those
 
it is currently not used
but that is a lucky coincidence of the code
approved design had a button
But sure, lets tr it without
buutton id on click function enter values...
trying to say in addition to the input box keyup we can have a button click function
i can dreambut I can't do
 
Hmm
So i removed the button
But now I just have to disable enter
 

  last day (26 days later) »