Silk UI Mobile Search in header - how to collapse programmatically

Silk UI Mobile Search in header - how to collapse programmatically

  

Hi,

I'm adding the "search" widget (Silk UI Mobile) in the "header right" placeholder to allow the user to input search criteria.

Currently the user must tap the "close" button to invoke the "collapse" of the search box and subscribe to the "OnCollapse" event and perform the search.

Is there a way that I can invoke "collapse" programmatically? I want to add 2 input widgets and a button in the "search area". When the user taps the button I want to "collapse" the search box and perform the search with input collected from user.


Thanks,

CJ

Solution

Hello CJ :)

You can do what you want by doing the following in javascript:

document.querySelector(".search").classList.remove("open")

The .search will be your selector (an id in case if you have more than one search in a page, or a class). 

Good luck!

Solution

Thanks Rita! Works like a charm