Lalibelamonk
Lalibelamonk

Reputation: 63

Call controller method on button click, without a redirect (rails 2.3)

I am new to rails, coming in from an angular background. Is there are way to have a button trigger a controller method without having the page redirect? I would also like to somehow tie input fields to controller variables without getting models involved.

What I have is a multi-page form (customer's design, not mine). On each page I want to validate user input, but I don't want to create a model for every field of what will end up being one cohesive object.

Upvotes: 0

Views: 528

Answers (1)

AKovtunov
AKovtunov

Reputation: 577

  1. You can call a controller action using AJAX. Just bind and ajax call on some button's onClick event and that's it. Also take a look at remote: true from jQuery-ujs

  2. You can also validate fields with JS if you don't want to touch models

Upvotes: 1

Related Questions