問題タブ [html5-data]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
javascript - Using sortable.js with html5 custom data attribute
How does one use html5's custom data attribute to sort items using sortable.js. Or how does one define custom sorting parameter using sortable.js
For example in the code below, I'd like to sort with data-timestamp
javascript - バニラJavaScriptでelement.dataset(DOMStringMapオブジェクト)を「実際の」JSONオブジェクトに変換しますか?
同様のStackOverflow questionで説明されているように、バニラ JavaScript では、次のことができます。
...すべてのdata-*
属性をオブジェクトとして取得するため。
ただし、結果のオブジェクトは「実際の」JSON オブジェクトではなく、ブール値と数値は引用符で囲まれています。
バニラ JavaScript と jQuery の比較は次のとおりです。
jQueryではjQuery('#my-element').data()
、実際のJSONを返す前にデータを「持ち上げる」という重い仕事をしていると思いました。
jQuery ではなく ES6 を使用したいので、ホイールを再発明したくないため (正規表現/条件を使用してその値を解析する)、この仕事を行う簡単な方法があるかどうかを尋ねています。