Skip to content

How to (old fasion) javascript library with lucky import? #1876

Answered by jwoertink
zw963 asked this question in Q&A
Discussion options

You must be logged in to vote

You should have a src/js/app.js file. In this file you should see

/* eslint no-console:0 */

// Rails Unobtrusive JavaScript (UJS) is *required* for links in Lucky that use DELETE, POST and PUT.
// Though it says "Rails" it actually works with any framework.
import Rails from "@rails/ujs";
Rails.start();

// Add this line
import IosSelect from "iosselect";

// now use the library like normal
var data=[{'id': '10001', 'value': '演示数据1'},{'id': '10002', 'value': '演示数据2'}];
var showDom = document.querySelector('#showDom');// 绑定一个触发元素
var valDom = document.querySelector('#valDom');  // 绑定一个存储结果的元素
showDom.addEventListener('click', function () {  // 添加监听事件
    var val = showDom.dataset['id'];

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@zw963
Comment options

@jwoertink
Comment options

@zw963
Comment options

Answer selected by zw963
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants