My recent submission (HTML5/Bootstrap Template) got soft rejected. The reviwer mentioned two issues - 1. PROPER EVENT BINDING and 2. CACHE JQUERY OBJECTS. I have tried to find and fix them by following resources and updated the JS file which I am using to control jQuery plugins. Can anyone please help me by checking it? I want to be sure before the resubmission.
Here is the updated file: https://www.dropbox.com/s/70j7c2zfbju7qv5/main.js?dl=0
Thanks in advance
Here some examples about what you should fix:
1- Event binding
$(’.list,switchToGrid’).click(function(e) // Do not use this way
$(’.list,switchToGrid’).on(‘click’, function(e) // Use like this
2- Cache jQuery Objects
// Don’t use like this.
Use like this:
var itemList = $(’.item-list’);
Thank you so much for your detailed instructions. I have updated main.js according to your recommandation It will be really helpful if you can check updated version from here: https://www.dropbox.com/s/ktv65h34m9kzpmh/main-updated.js?dl=0
Have nice day
Almost there. You don’t need to declare itemList twice. Just move it top of the code and you can declare variables for $(’.grid’), $(’.list’) too. If you will use jquery object more than 2, just create a variable and use it like that.
Hi @eony, Just made the changes
Now, it seems OK Please, let me know your opinion.
Thanks for your co-operation
Yes, it is okay. You can tidy the code a little but it is up to you.
Yes, will do that and Thanks a lot for your help