JackAdams / meteor-editable-text

Drop-in editable text widget for meteor

Home Page:http://editable-text-demo.taonova.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I change the value of the widget in (or after) my afterUpdate callback?

chrisco23 opened this issue · comments

I've tried everything I can think of. Specifically, I want the user to enter some dollar figure, and in the end, I want to to use the accounting package, formatMoney method, to make sure in the end the user ends up with a nicely-formatted currency.

But I cannot even make the input change to 'foo', let alone a formatted currency.

A similar issue came up yesterday. Either something isn't working or I've documented it wrongly. I'll be looking into it soon.

Sent from my iPhone

On Oct 21, 2015, at 2:00 PM, Chris Cortese notifications@github.com wrote:

I've tried everything I can think of. Specifically, I want the user to enter some dollar figure, and in the end, I want to to use the accounting package, formatMoney method, to make sure in the end the user ends up with a nicely-formatted currency.

But I cannot even make the input change to 'foo', let alone a formatted currency.


Reply to this email directly or view it on GitHub.

Thanks. Just to clarify, I'm only trying to change the display after the update is made. So a user enters, say "1000000", and the document updates the document field to 1000000 (so far so good, this works per the docs) but at the end I want to modify the display, in my case it will become $1,000,000. I couldn't find if there is even supposed to be a way to do such a thing really.

Try editingValue=rawDBvalueFromHelper and value=modifiedValueFromHelper in the widget initialization.

Sent from my iPhone

On Oct 21, 2015, at 2:32 PM, Chris Cortese notifications@github.com wrote:

Thanks. Just to clarify, I'm only trying to change the display after the update is made. So a user enters, say "1000000", and the document updates the document field to 1000000 (so far so good, this works per the docs) but at the end I want to modify the display, in my case it will become $1,000,000. I couldn't find if there is even supposed to be a way to do such a thing really.


Reply to this email directly or view it on GitHub.

No luck but maybe the fault is in my callback though? I've tried everything I can think of in the callback. every variation on changing the dom with jQuery (and straight JS), trying various tricks with "newValue"... Maybe I'm missing something simple about changing the value (post-update) in the callback? I can see this.newValue and I can change it at that point but I assume then after the callback the value is still coming straight from the user input anyway, or something like that?

Hi chrisco23. I am having the 'similar issue'. Just a few quick questions. Are you hoping to store the formatted number in the db, or only display it in the display? Are you using collection2, and if so, what is the data type of the field?
Also, what version of this package are you using?

Hi again Chrisco23. I am able to get working results for what you are requesting using the following:

{{> editableText collection="deals" field="cap" value=capH editingValue=cap type="number" acceptEmpty=true}}

The field name is 'cap'. When i click to edit, it simply displays the numeric field without any formatting, so it also uses 'cap', but after i leave the field is uses the template helper 'capH' to display the number formatted with commas. Note above which fields have quotes, and which haven't.

Thank you dpatte! and JackAdams too because I see now what your earlier post meant.

I never saw anything in the readme about being able to call a helper, nor about the value= nor editingValue= so I was trying endlessly to use the "afterUpdate" registered callback with no luck.

I should probably still consider what makes sense for the user when doing the edit (wish there was some package that would display the $ and the currency formatting as the edit was taking place) but this solves my problem.

Glad to help

I use the following commas formatter. it may be of help

if (!num) return '';
if (window.Intl && typeof window.Intl === "object")
  return num.toLocaleString();
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");

That's in your helper, though, right? The user still just enters an integer?
I'm using lepozepo:accounting since I have a lot of financial data. My helper is now just:
return accounting.formatMoney(this.cash);

yes chrisco, its in my helper. But under your advice, I'll also look at lepozepos accounting module :)