How to implement dependent dropdowns in Rails 4 with an unobtrusive jQuery script

I recently had to implement a view with the classic search form with two select dependent on each other. My aim was to leave the page as clean as possible and make the code that loads the options for the daughter dropdown reusable.Suppose, therefore, to have two models, SpecializationType and Specialization, defined as follows:1234567891011121314151617181920212223242526272829303132class SpecializationType < ActiveRecord::Base # F...

Read more

How to implement two dropdowns dependent on each other using Django and jQuery

Hello everyone.With today’s article I want to show how to implement two dropdowns dependent on each other using Django and jQuery.Suppose we have a 1-N relationship between car brands and car models: we want to show the list of brands in the first dropdown; then once you have selected a brand, the second dropdown will show a list of filtered models for that brand.Suppose we have our models defined as follows:123456789#models....

Read more
Ruby on Rails and jQuery: multiselect with checkbox

Ruby on Rails and jQuery: multiselect with checkbox

Today I want to present a very convenient jQuery plugin I’ve used to create a combo box with checkboxes for a multi-selection field.Suppose we have a form of insertion / modification of user data, and that the user can have multiple functions. We start with rendering the form with a multi-selection field, where you can select more functions with the combination “<ctrl> + click “.12...

Read more