formatCurrency = function( num ) {
return $('<span />').text( num ).formatCurrency().text();
}
$('#button').on('click', function() {
$this = $(this);
for (i=1.5; i<=10.5; i++) {
$this.parent().append('<p>'+formatCurrency(i)+'</p>');
}
});
This code should create 10 paragraph tags, each with a different dollar amount,
and append them to the parent of the #button element. However, because both
this function and the plugin use "$this = $(this);" there is a scope issue, and
my local variable $this gets overwritten.
While this issue can be corrected by changing my local code to an explicit
declaration ("var $this = $(this);") the plugin should explicitly declare $this
as a new variable to prevent this from happening.
Original issue reported on code.google.com by tyler.vi...@gmail.com on 3 Jul 2012 at 9:48
Original issue reported on code.google.com by
tyler.vi...@gmail.com
on 3 Jul 2012 at 9:48