Skip to main content

We would like to create an action that clears the search box, rather than having a user delete the text value in the box. I set up a button that ran a snippet, but was unable to get the js to clear the box. Does anyone have any code that would work for this? Or a better idea on how to clear the search box?

You could do something like this:


var $ = skuid.$;<br>var search = $('input.searchbox');<br>search.val('');

I would suggest that you use the unique id of the table like this $(‘#tableid input.searchbox’).val(‘’); if there are other tables on the page. 

This would only clear the value from the box but the search would still be in effect on the table. To actually clear the search from the table you have to run the script below


var model = skuid.$M("modelName");<br>var searchCondition;<br>for (var i = 0; i &lt; model.conditions.length; i++)<br>{<br>if (model.conditionsoi].name.indexOf('searchbox')!=-1)<br>{<br>searchCondition = model.conditionsoi];<br>}<br>}<br>model.deactivateCondition(searchCondition);<br>model.updateData();

Thank you Moshe and Menachem! I was able to get it working with this code. Much appreciated!


This isn’t working for me. I have a page with multiple tabs & tables, so maybe that’s the problem? When I try to call this it just hangs. I think there is a condition called “18_searchbox”, but even when I hardcode that it won’t clear the searchbox or the condition.


Correction: It does seem to find and clear the search value when the table search is in use, however it takes about twice as long as clearing other table filters and does not blank out the search box, so it is confusing. I’ve tried variations of:

var $ = skuid.$;
$(‘projects input.searchbox’).val(‘’); 

But it haven’t yet found something that clears the text in the searchbox.


This still not working? If you set the Id of the table to “projects”, then it looks as though you need insert “#” into your code in order for the select to work.

var $ = skuid.$;
$(‘#projects input.searchbox’).val(‘’); 


I’m not sure where the problem is, as I seem to get different problems at varying times. I’m trying to do a real “clear searchbox and requery” button, but can’t get it to work. Here’s the code I have:


// deactivates the table searchbox condition for the given model var $ = skuid.$; $('#ProjectsLive input.searchbox').val(''); var model = skuid.$M("projects"); var searchCondition; for (var i = 0; i &lt; model.conditions.length; i++) { // alert(model.conditionsli].name); if (model.conditionsli].name.indexOf('18_searchbox')!=-1) {searchCondition = model.conditionsli];} } model.deactivateCondition(searchCondition); // don't want to do the model refresh here as it wlll happen as an action on the button when other filters are cleared as well //model.updateData();<br>

Reply