You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and trying to reference this.$el. When this method is called, this isn't top element where EmployeeView is instantiated, but reference to clicked button. (this works by accident since you have classes for other buttons which would then show this image).
tbh, second part in in jQuery selector (this.$el) is not needed.
Your query always return 8 media-objects (since there are so many of them on screen) and you are changing src of each of them.
What you should do is this:
on beginning of initialization store this into var that:
var EmployeeView = function(employee) {
var that;
this.initialize = function() {
that = this;
this.$el = $('<div/>');
this.$el.on('click', '.add-location-btn', this.addLocation);
this.$el.on('click', '.add-contact-btn', this.addToContacts);
this.$el.on('click', '.change-pic-btn', this.changePicture);
};
2). When searching for element to change src do this:
Parts with referencing this are completely wrong imo... you have:
and trying to reference this.$el. When this method is called, this isn't top element where EmployeeView is instantiated, but reference to clicked button. (this works by accident since you have classes for other buttons which would then show this image).
tbh, second part in in jQuery selector (this.$el) is not needed.
Your query always return 8 media-objects (since there are so many of them on screen) and you are changing src of each of them.
What you should do is this:
2). When searching for element to change src do this:
this way for sure you'll only get one element
The text was updated successfully, but these errors were encountered: