Understanding Materialize predefined functions for "chips"

Understanding Materialize predefined functions for "chips"
0
#1

I’m using the “chip” class in the Materialize framework for my Twitch project: http://codepen.io/AbdiViklas/pen/PzgRbj?editors=0010 . I’m also working on storing the list of channels in localStorage. The .chip class comes with a handy little “close” button, which works great at getting the chip off the screen, but now I want to write a function that says “and stay out,” deleting the value from localStorage. Materialize seems to have something like that set up, but frankly I need a translator.

  1. I hear a lot about “Initialization.” I’m already using these “chips” as a css class. Do I need to include this “jQuery initialization” block of code in order to use the functions that follow?
  2. In http://materializecss.com/chips.html#events, there’s the chips.delete function that I need. But when it says function(e, chip)–what is e? And what exactly is chip–the data inside it? the html?
  3. These examples use the class chips. Higher on the page, when it’s just talking about the css, it uses chip, no “s”. Is this significant?

I tried this:
``$(’.chip’).on(‘chip.delete’, function(e, chip){
console.log(“deleted”);
});
… changing “chips” to “chip,” since I actually use that class, and nothing was logged when I clicked an X. I’m stumped.

0 Likes