Dashboard: Don't trigger an Events search when the search field is empty.

Fixes #40816.


git-svn-id: https://develop.svn.wordpress.org/trunk@40799 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrea Fercia 2017-05-19 17:26:06 +00:00
parent cc214db09f
commit 99dde26730

View File

@ -234,10 +234,20 @@ jQuery( function( $ ) {
$container.on( 'click', '.community-events-toggle-location, .community-events-cancel', app.toggleLocationForm );
$container.on( 'submit', '.community-events-form', function( event ) {
var location = $.trim( $( '#community-events-location' ).val() );
event.preventDefault();
/*
* Don't trigger a search if the search field is empty or the
* search term was made of only spaces before being trimmed.
*/
if ( ! location ) {
return;
}
app.getEvents({
location: $( '#community-events-location' ).val()
location: location
});
});