NeXTs / Jets.js

Native CSS search engine
https://jets.js.org
MIT License
2.8k stars 108 forks source link

Option to add search string to URL #9

Closed tliebig closed 8 years ago

tliebig commented 8 years ago

Hey Den,

would it be possible to incorporate html5 PushState to add the search string to the url? I've been using this to deeplink to search results with dynatable.js, which is quite handy: Just copy the URL after searching and share it via email to point other users to solutions within larger databases.

This is how dynatable.js does it: http://www.dynatable.com/#pushstate

Alex-Sokolov commented 8 years ago

You can use didSearch method and made everything what you want:

didSearch: function(search_phrase) {
  console.log(search_phrase);
}
NeXTs commented 8 years ago

Hi Torsten, use didSearch method proposed by Alex to mutate URL as you wish

tliebig commented 8 years ago

Worked great, thx.

How about the other way around - pick a the search phrase from the url, and execute the search. I am able to do the first, but I cannot execute the search afterwards.

I've tried triggering the keyup event on the searchInput, as well as triggering the change event, but to no avail. Couldn't find anything in the docs as well.

Could anyone point me in the right direction?

NeXTs commented 8 years ago

@tliebig Take a look http://codepen.io/NeXTs/pen/yYxazx?editors=101

due to http://stackoverflow.com/a/2856602/1221082

tliebig commented 8 years ago

@NeXTs Works like a charm, thanks!