<script type="text/javascript"> //<![CDATA[ // Preset selected order articles per template order: var template = new Array(); <% current_article_ids = @order.supplier.articles.available.map(&:id) -%> <% i = -1; for order in @template_orders -%> template[<%= i += 1 %>] = new Array(<%= current_article_ids.collect { |id| order.article_ids.include?(id) }.join(', ') %>); <% end -%> // Call with index into template-array to select order articles from template. function useTemplate(id) { if (id >= 0 && id < template.length) { <% i = -1; for article_id in current_article_ids -%> var status = template[id][<%= i += 1 %>] $('checkbox_<%= article_id %>').checked = status; highlightRow('<%= article_id %>',status); <% end -%> } } //]]> </script>