I don't understand why $('#searchbox').live prevents my search input to be typed in. I can log the event but nothing shows up. But when I comment out the searchbox line it suddenly seems to allow text in the searchbox. Plus the search function via the magnifying glass click works! Very strange.
Has anyone had an issue like this?
The reason I structured it this way is because I want this function to be used by my other applications.
function initModuleSearch(selector){
$('#clear_x').live('click', {name:'clear', id:selector}, performSearch);//clears search
$('#magnify').live('click', {name:'find', id:selector}, performSearch);//submits search
$('#searchbox').live('keyup', {name:'enter', id:selector}, performSearch);//submits search
return false;
}
function performSearch(evt){
var eventType = evt.type;
var eventName = evt.data.name;
var selector = evt.data.id;
var searchInput = $('#searchbox');
console.log('Hello:' + eventName)
//do some search and filter stuff below here
evt.preventDefault();//disallow browser to perform default action
return false;
}
initModuleSearch(".module");//init searchbox function
evt.preventDefault();
or even return false
will prevent you to type anything in the textbox.
If you feel its not required then remove it from the method.