I have this class in which I am using a jQuery inside but I can not get it to work. I know where the issue is. It is in the line this.clicked_ac_list = $( this )
. How can I access the selected dynamic element .ac-list
?
//class to manage filter
function filter( ){
this.keyword = { word:"", matching:"" };// matching exact, prefix, infix
this.category = "";
this.filters = [ ];// an array of {key:"",value:""}
this.ac_results = $( ".ac-container .ac-results" );
this.ac_results.on( "click" , ".ac-list" , function( ){
//the issue is in this line
this.clicked_ac_list = $( this );
this.category = this.clicked_ac_list.attr( "data-category" );
this.keyword.word = this.clicked_ac_list.attr( "data-keyword" );
console.log( this.category );
console.log( this.keyword );
}.bind( this ) );
}
var filter = new filter();