0

In my APEX application I have some calculation routine implemented in Javascript. The input is taken from multiple Text Fields. I want the calculation routine to work each time any of those Text Fields has been changed. Using Dynamic actions, how can I share this Javascript function among multiple Text Field change actions? Preferably avoiding any CSS modifications.

Drumbeg
  • 1,914
  • 1
  • 15
  • 22
Pablo
  • 28,133
  • 34
  • 125
  • 215
  • Can't you use the `onChange` evenhandler on all your textboxes point it to a single js function? – David R Aug 26 '16 at 07:36
  • Question is where this js function will reside? Naturally I put it into Dynamic Action. But then I will have as many Dynamic Actions as Text Fields I have and copy of JS function everywhere. – Pablo Aug 26 '16 at 07:38
  • Can't you have a unique css class (for all your dynamic textboxes) so that you can put up a jQuery evenhandler based on that single class selector through which you can avoid copying the JS function everywhere. – David R Aug 26 '16 at 07:41
  • I thought putting javascript in css is bad idea and hoping there is natural way for APEX to accomplish this. If you have some complete answer in context of APEX (where to put that JS function exactly), then you are welcome to post an answer. – Pablo Aug 26 '16 at 07:45
  • Okay. Got it! :-) – David R Aug 26 '16 at 07:47

1 Answers1

2

You can select multiple page items when specifying your single dynamic action to fire on change. They are comma separated in the Item(s) field (clue is in the name).

Also, as mentioned in the comments above, you could use a CSS class to group your items. As for whether this is a bad thing, check out this question.

Best practice: class or data attribute as identifier

Personally, I feel comfortable using classes to allow for easy jQuery selectors and it is both very common and natively supported in APEX.

Community
  • 1
  • 1
Drumbeg
  • 1,914
  • 1
  • 15
  • 22