Skip to content

Callback on multiple drawsvg elements #16

@danielucas

Description

@danielucas

I'm running .drawsvg within a .each loop to draw all the SVGs on my page, however when I try and use $(this) or any variable scoped within the .each, it does not work - my variables are not passing to the callback. Or rather, the LAST variable defined in the each (so my last item) is the variable that gets passed to ALL the callbacks.

For example, I have the letters: R E N - and every callback returns N in the console.log - instead of each returning the correctly scoped variable letter.

I've tried passing the variable through like callback: function(letter) - but this has no effect.

Help?

$('.logo-letter').each(function(){
var letter 	= 	$(this),
	thisSvg = 	$(this).find('svg'),
	mySvg 	= 	thisSvg.drawsvg({
			callback: function() {
						console.log($(this));
						letter.addClass('loaded');
					}
				});
	mySvg.drawsvg('animate');
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions