Developing a site with Yii framework.
When I type keywords to search in the GridView filter input box and then hit Enter – the form is not submitted to the server.
But hitting Tab or clicking with a mouse outside the input field – does work.
The problem is in IE and Opera. Firefox is fine.
EDIT
dInGd0nG suggested this forum topic with a workaround for similar problem but jquery.yiigridview.js code has changed since the post of that workaround. It now uses on() function instead of live().
The code is pretty different now, I’m not sure I’ll be able to come up with new workaround myself.
Can anybody adapt that patch for current jquery.yiigridview.js?
So, as far as I understand, this is the piece that handles submition of filter input.
$(document).on('change', inputSelector, function () {
var data = $(inputSelector).serialize();
if (settings.pageVar !== undefined) {
data += '&' + settings.pageVar + '=1';
}
$('#' + id).yiiGridView('update', {data: data});
});
It works in Firefox and doesn’t work in IE or Opera.
Any ideas how to fix it?
EDIT 2
I came up with this to make IE and Opera send filter request on hitting Enter key.
if($.browser.msie || $.browser.opera) {
$(document).on('keypress', inputSelector, function(event){
if(event.keyCode == 13) {
var data = $(inputSelector).serialize();
if (settings.pageVar !== undefined) {
data += '&' + settings.pageVar + '=1';
}
$('#' + id).yiiGridView('update', {data: data});
}
});
}
But it’s kinda ugly.
This is an issue with jquery as stated here. That page also has a work aorund. Have a look at this forum post too.