nipplejs
nipplejs copied to clipboard
Add support for overwriting the buildEl function
I needed to customize the HTML of the nipple elements, so I'm adding support to overwrite the buildEl
function. Any suggestions on how this could be improved are welcome.
If you could add some documentation on how to use this, it would be 👌
Hey @yoannmoinet, thanks! Added more checks, and added it in the Readme. I can't get all tests to pass, but most fail on the current master as well. I'll try to add a test for a simple className
added via buildEl
, and maybe I'll have time for an example as well.
One idea I had was to change this into a hook function? Instead of overwriting the whole buildEl()
, I could add another function that gets called right after it?
// nipple.js:43
this.buildEl()
.stylize();
// would become:
this.buildEl();
if (this.options.dataOnly === false) {
this.collection.afterBuildEl();
}
this.stylize();
WDYT?
Sorry for the delay @vladfr (started a new job in January). I'll have a better look at this because this is a great idea, but I'm not sure about the implementation. I feel like it's a bit complicated for a dev to implement a full function just to have his own element.
I'll figure something out.
Hi,
Yes I hear you. That's why I didn't really push for it... It did the trick as a hack, but indeed it should be done more cleanly.
On Mon, Mar 11, 2019, 10:30 Yoann Moinet [email protected] wrote:
Sorry for the delay @vladfr https://github.com/vladfr (started a new job in January). I'll have a better look at this because this is a great idea, but I'm not sure about the implementation. I feel like it's a bit complicated for a dev to implement a full function just to have his own element.
I'll figure something out.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/yoannmoinet/nipplejs/pull/98#issuecomment-471447295, or mute the thread https://github.com/notifications/unsubscribe-auth/AAM-hzuZ4dCG89TkS2JnuE1aGnv-_p5jks5vVhQ8gaJpZM4aobrK .