Hey there people,
i am encountering an error somewhere with a script i have written. so ive turned to this forum for some guidance.....
in a page im working on at the moment i have a table that is populated with data from a mysql database. when the DOM is ready i attatch a .click event handler to the table row in the table - the aim is to allow the user to select a row which will then give it the class 'selected' and enable a button with a dropdown menu with tasks that can be performed on the selected object, eg. delete, edit, view, mark complete.
the issue that i have come across is that when i select a row, it adds the class 'selected' to it and enables the button, but if i click on it again instead of emulating a deselect (removing the class 'selected' and disabling the button) it does nothing at all.
i have added console.log lines to the script to show me where the script is going on certain points and to log whether hasClass is returning true when i check for 'selected' in the class of the table row that is being clicked on. but each time i click on it i get a return of false.. i really dont know why its doing it as the DOM clearly shows that the table row has the class 'selected'
i have created a jsfiddle to help with this issue and it is doing the same there too...
http://jsfiddle.net/6hf98k72/2
i hope someone can point out any errors with the script as i cant see where i am going wrong....
thanks in advance