rails_admin change dropdown enum with javascript - ruby-on-rails

I've override rails_admin edit and new form and controller via routes,
and added a javascript to watch for on change of country dropdown,
and refreshed the state dropdown.
but i couldn't find a way to replace the dropdown for state or manipulate the list.
does anyone know what script is rails_admin using for drop down?
I've tried to manipulate the select dropdown, but its been replaced and hidden by a script.

Related

dynamic dropdown populate in haml

I have two dropdowns and a submit button on a rails form HAML page. I would like dropdown 2's content be populated dynamically based on dropdown 1 selection, and submit the form based on both of two dropdown's selected values.
I know how to do the submit part, but I'm a bit lost on the dynamic rendering for dropdowns. I can let dropdown 1 to call a controller method to update db (used by dropdown 2) and redirect to the form. This doesn't seem to perform well. Any suggestions on how to write the two dropdowns?

Dynamic Multiple dropdowns for select2 plugin

I working on select2 plugin and I am need some help here.
I have a select2 dropdown and when selecting from the dropdown , I need to create another dropdown below the 1st dropdown with options excluding the one already selected. So, there will be dropdowns as many as options.
I know there is a option for Multiple, but I want like 'single block'.

Formtastic with multiple ajax calls

I'm trying to figure out the rails way to use formtastic to build out a couple of dropdown boxes and then based on those values make some ajax calls. For example:
At the top level my model is a PostOffice with a location_id
User selects dropdown #1 which is a list of states.
When dropdown #1 is changed dropdown #2 is populated with cities via an ajax call
When dropdown #2 is changed dropdown #3 is populated with addresses via an ajax call
User clicks 'get info' and the form submit happens.
Do I need to build out multiple semantic_form_for calls in my view to populate subsequent dropdown boxes? I can get this to work using a bunch of jquery but it's resulting in some unmaintainable code. Seems like I need to have it setup so that when I change dropdown #1 I need to make a request that generates a partial for dropdown #2.

Make collection_select display as an image (Rails 3 App)

All,
BACKGROUND: I have a collection_select statement that displays a dropdown box.
OBJECTIVE: I'd like the dropdown to be an image that the user clicks to see the collection rather than the default box + down arrow that appears.
You need something like this plugin for jQuery. It allows you to replace a normal select with a custom one based on your wants. You would have to write your own select helper since you need to add the attributes to the select options that this plugin requires. If you get started and need help, post back here with what you're stuck on.

How to get multiple and individual update actions on product lines in mvc?

I've got a list of products in an admin section of my website. I have the product title and then an icon for delete and an icon for set visible/set invisible. I have both icons wrapped in their own form elements so they fire seperate Actions. I now one to add some checkboxes to each line so I can do a bulk delete. Following this:
How to handle checkboxes in ASP.NET MVC forms?
I'd need to wrap the whole list in a form tag to return the checkbox values, but then I have the icons on each row wrapped in form tags. I'm not sure what to do or how to handle this so it all works. How can I maintain the line form tags but still get bulk update functionality?
It's probably going to require some JavaScript. I would create a form outside of the table with a hidden element. When a box is checked, update the hidden element to contain a comma-separated list of all the IDs for rows that have the checkboxes checked (this would be pretty straightforward with jQuery). When that form is submitted, parse the values of the hidden element and delete accordingly.
Another option is to wrap the whole thing in one form and make the names of the delete buttons unique, then check for that when the form is submitted. When doing a bulk delete, you'll have all the checkbox values submitted like normal and you'll know it's a bulk delete based on which button they pressed to submit the form.

Resources