Home Rails 4: How to multiply in a view an element based of how many times was selected
Reply: 0

Rails 4: How to multiply in a view an element based of how many times was selected

Jakub
1#
Jakub Published in 2017-12-07 09:12:02Z

In my Rails 4 app, I have a table which contains some elements and that element can be selected just adding a tick. Every element can have more of one tick or zero ticks. On the side of this table, I have a button called generate. When it is pressed a list of the elements is shown. like:

  • Element 1
  • Element 2
  • Element 3

What I need is to show the repetition of the same element for how many ticks its has. like: Example Element 1 has 3 ticks, Element 2 has 1 tick, Element 3 has 4 ticks. The list should look:

  • Element 1 (Tick1)
  • Element 1 (Tick2)
  • Element 1 (Tick3)
  • Element 2 (Tick1)
  • Element 3 (Tick1)
  • Element 3 (Tick2)
  • Element 3 (Tick3)
  • Element 3 (Tick4)

Also what I need to show on top of every repeated Element a title saying like 1,2,3...

Will be good to see an example through JSFiddle to understand the method for this or some other example in Rails.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.338287 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO