How to use tomselect to create and edit a "belongs_to :many relation" with Ruby on Rails

This page summarizes the projects mentioned and recommended in the original post on dev.to

SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
surveyjs.io
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
  • tom-select

    Tom Select is a lightweight (~16kb gzipped) hybrid of a textbox and select box. Forked from selectize.js to provide a framework agnostic autocomplete widget with native-feeling keyboard navigation. Useful for tagging, contact lists, etc.

  • import { Controller } from "@hotwired/stimulus" import { get } from '@rails/request.js' import TomSelect from "tom-select" // Connects to data-controller="search" export default class extends Controller { static values = { url: String, selected: String } connect() { this.element.setAttribute( "autocomplete", "off" ); if (this.selectedValue == 'null') { var selected_json_data = new Array() var selected_items_array = new Array(); } else { var selected_json_data = JSON.parse(this.selectedValue) var selected_items_array = new Array() for(let i = 0; i < selected_json_data.length; i++) { selected_items_array.push(selected_json_data[i].id) } } var config = { plugins: ['clear_button', 'remove_button'], shouldLoad:function(q){ return q.length > 2; }, render: { option: this.render_option, //item: this.render_option item: function(data, escape) { return `${escape(data.email_address)}` } }, loadThrottle: 300, // check this out in search items reload new data-> // https://github.com/orchidjs/tom-select/issues/78 // https://stackoverflow.com/questions/74622800/fetching-data-from-api-to-create-tom-select-options maxItems: 10, maxOptions: 10, valueField: 'id', labelField: 'email_address', searchField: ['email_address', 'first_name', 'last_name'], options: selected_json_data, items: selected_items_array, sortField: { field: "email_address", direction: "asc" }, create: false, load: (q, callback) => this.search(q, callback), } let this_tom_select = new TomSelect(this.element, config) this_tom_select.clearCache() } async search(q, callback) { const response = await get(this.urlValue, { query: { q: q }, responseKind: 'json' }) if(response.ok) { callback(await response.json) } else { callback() } } render_option(data, escape) { if(data.email_address) return ` ${escape(data.first_name)} ${escape(data.last_name)} | ${escape(data.email_address)}

  • rails_7_modal_form

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Tom-select: vanilla JavaScript select control

    1 project | news.ycombinator.com | 17 Apr 2024
  • Glam Up My Markup Contest Submission | Special Effects with backdrop-filter() ✨

    1 project | dev.to | 29 Mar 2024
  • A comprehensive guide to multi-timezone support in Django

    2 projects | dev.to | 11 Oct 2023
  • Hide an API Key from JS code

    1 project | /r/learnjavascript | 26 Jun 2023
  • Slim Select v2.0 Release!

    1 project | /r/javascript | 20 Nov 2022