jquery - "hasClass" synonym in rails -


in app need check if span id="transaction_sign" has class negative , if - add "minus" number, user has entered in field , save in negative form database.

in fact, if using jquery , rails need this:

def add_sign_to_transaction     if $('#transaction_sign').hasclass('negative') {         @transaction.amount *= -1      }; end 

but, of course can't in in transaction_controller.rb file, need put def before_filter.

is there way check css on page in rails? or maybe need gems it?

your form should send either:

  1. transformed data in first place, or
  2. enough additional data transformations on server side.

view-layer representations brittle substitutes appropriate models.

the technical answer question no, unless view layer altered server-side code , not js. if client alters style(s) should either send right data or flag. flag could, of course, hidden field set style of form element, or boolean triggered presence of given style. imo that's wrong approach: send negative number.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -