[AJAX]: Passing object properties values into model properties in views

I've a simple scenario, where I've a dropdown using ajax, which after changing value, should reload some data in view. For simplicity, I've created a simple test case, but because my JS skills are week I've stucked, I don't know how to modify my script to update more than one value during ajax request.


actiom method in controller

I want to return in action selectConfigSet a AR instance (please see commented code) with a one single row. I want to pass a data from it into textfields ‘description’ and ‘points_for_vicory’. Problem is that I don’t know how :(

I've found solution which almost fullfills to my needs.


actiom method in controller

Only one problem which left, is how I can update a label instead of input field?

Two suggestions:

  1. Uniquely label your wrapping div or form tag with an "id" tag. Then in your JS you can use document.getElementById() then change the label from there.


  1. Pass the parameter "this" (without $) into your JS function. "this" represents the calling object. You can then walk up the parent chain to find your label.

Neither of these are hard. If you send me your entire <form> code, I'll show you what to do.