locbet / jquery-numberformatter

Automatically exported from code.google.com/p/jquery-numberformatter
0 stars 0 forks source link

Prefixes or suffixes break, when running format() on multiple items #24

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
$('<p>1</p><p>2</p><p>3</p>').format({format:'Price: #,###.00 €'})

will output:
<p>Price: 1.00 €</p><p>2.00</p><p>3.00</p>

where it should be:
<p>Price: 1.00 €</p><p>Price: 2.00 €</p><p>Price: 3.00 €</p>

Solution:
Move lines 215-243 before line 209 (return each...)

Regards, Blaz

Original issue reported on code.google.com by mihel...@gmail.com on 12 May 2010 at 5:17

GoogleCodeExporter commented 8 years ago
It's not the intention of the library to perform standard jquery operations for 
you.

If you wanted to iterate over several items and format them then you would do 
just 
that, using the each() method in *your* code to format one at a time.

Original comment by apar...@gmail.com on 13 May 2010 at 4:25

GoogleCodeExporter commented 8 years ago
Sorry, but you are wrong here.

Your method ALLREADY performs iteration on all matched items, see line 209 
(return 
this.each....) as it also should, to be compliant with jquery plugin authoring 
recommendations, but it does that in wrong way! On the second and all 
subsequent 
items it "forgets" about prefixes and suffixes, it does only formatting.

If your intention was, to only format the first item (which would be very non 
jquery 
approach), also have to rewrite your code...

Take a look at an example I gave you... This cannot be intended behaviour!!!

Regards, Blaz

Original comment by mihel...@gmail.com on 13 May 2010 at 4:41

GoogleCodeExporter commented 8 years ago
Ok, looking at your closed issues, I see that my issue is actualy a duplicate 
of #19.

What I don't understand is, why don't you make a bugfix release of version 
1.1.2, 
because this bug is really huge and the fix really simple...

Regards, Blaz

Original comment by mihel...@gmail.com on 13 May 2010 at 4:47

GoogleCodeExporter commented 8 years ago
Ahhh ok sorry, I forgot the old code did that, been working on the revamped 
code recently so not seen the 
old code in quite a while, I think the new code doesn't do that, or at least 
has this particular issue 
fixed. I go so long between dev sessions I forget what the code does :p

There is no bugfix release for 1.1.2 because when I took over the code there 
was quite a lot of problems 
both logged here and structural, I knew with the limited time I have for the 
project it would take me ages 
to fix them all (some had been open for 1 year+) then only to carry out the 
planned revamp later on.

So I went straight ahead and did the revamp, it's currently on here as 1.2 
beta, while it's still not 100% 
reworked to be more reliable, clearer and faster it does incorporate the fixes 
I've closed since taking 
over the project.

So I would recommend taking a look at 1.2, perhaps it's stable enough for what 
you need, main changes are 
a complete separation of parsing and formatting (format= std notation -> 
formatted, parse= formatted -> 
std notation), see notes for more details.

I'll look into this more wrt the each() internal usage, perhaps it is wrong as 
you say still and not in 
line with jquery guidance.

Original comment by apar...@gmail.com on 13 May 2010 at 5:37

GoogleCodeExporter commented 8 years ago
Working as of 1.2 as expected, see attached.

Original comment by apar...@gmail.com on 9 Oct 2010 at 11:38

Attachments: