Chainable?
Closed this issue · 1 comments
Are you able to make the plugin "chainable" or add an event?
For example, I tried to add a class after calling letterpic and get a Cannot read property 'addClass' of undefined
error.
$(".letterpic").letterpic().addClass('pointer');
Am I doing this wrong? I tried using deferred.then()
, but it didn't work either.
My use case is: I'd like to identify elements that have a successfully loaded images (identified by an undefined "width" attribute) and add a click event to use MagnificPopUp to display a larger version of the image (or launch a upload tool, editor, crop-tool, etc.)
NOTE: I'll probably work around this by changing my trigger to use img.letterpic
.
Thanks for feedback.
I added chaining to plugin. Also I added two events, you can pass in options on plugin init:
$(".letterpic").letterpic({
onElementReplaced: function($el, isBrokenImage) {
console.log($el, isBrokenImage);
},
onImageError: function($el, url) {
console.log('Image loading error: ' + url);
}
}).addClass('pointer');