ruby on rails - jQuery matched set to string -


I need to sort a matching set so that my prices can be sent to my rail app.

is the matched set code (returns the parent device of each unpublished selection element):

  jQuery (select '). Filter (function (index) {return jQuery (this) .val () == 0;}) The nearest ('div')  

For serialization, I really need the ID of each matched element, so I tried:

  jQuery ('Selection'). Filter (index (index) {returns jquery (this) .val () == 0;}) closest ('div'). Attr ('id')  

Unfortunately attr () works on the first element only in the matched set.

Since the resultant JavaScript Rail ' with remote_function: I believe JavaScript can only be a statement.

How can a matching set be serial, or for string?

For variety, here is an answer using the map : < / P>

  Result = jQuery (Select '). Filter (Function (Index) {Return jQuery (this) .val () == 0;}) .closest (' div ') .map ( Function () {this.id;} return) .get () // Stop here if you want an array (','); // or if you want a string here  

Comments