file location is: yiiroot/framework/widjets/assets/gridview/jquery.yiigridview.js
I need to change one line in this file so that I can use it in my requirements.
the original code is:
if (settings.ajaxUpdate.length > 0) {
$(document).on('click', settings.updateSelector, function () {
$('#' + id).yiiGridView('update', {url: $(this).attr('href')});
return false;
});
}
I want to change it to:
if (settings.ajaxUpdate.length > 0) {
$(this).parent().on('click', settings.updateSelector, function () {
$('#' + id).yiiMyGridView('update', {url: $(this).attr('href')});
return false;
});
}
Now, what is the right way to override this without needing to change a yii source code file?
PS, to be honest I don’t know why exactly I had to make this change, but I know very well that I need to do it. Making this change has made my live happy again.
I don’t know if it’s a good thing for you to do this work around in the long run.
The original on(‘click’) is assigned to $(document), so that it will be effective after the grid is updated by ajax.
And maybe you had to cancel the on(‘click’) after ajax update by assigning it to $(this).parent() … which is reloaded by the ajax and on(‘click’) will be forgotten.