Is there a Clojurescript library to replace jQueryUI sorting?

What the name says. I have a simple application that needs functionality, but could be otherwise written in the usual clojurescript, so it’s just useless to download jQuery and jQueryUI.

+4
source share
3 answers

Closest thing to jQueryUI Sortable in google close library goog.fx.DragListGroup . As far as I know, there is no ClojureScript cover for this, but it is quite easy to copy directly from it, and since it should also be well optimized in the closing library. The basic idea is that you create an instance of DragListGroup for each independent list that you want to sort, and then add the list item to this group using addDragList . You can also add multiple list items to the same group if you want to drag items between lists.

+2
source

Here is one way to make it work. You will need to use an external file so that Google Closure can read jQuery libraries. There is one for the main jQuery already published , and I published it, which works well for sorting jQuery-ui . Project.clj should have a link to extern, so include something like this:

 :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/clojurescript "0.0-1806"] [jayq "2.3.0"]] :plugins [[lein-cljsbuild "0.3.1"]] :cljsbuild { :builds [ {:source-paths ["src"] :compiler {:output-to "resources/public/js/out.js" :optimizations :advanced :pretty-print false :externs ["resources/public/externs"]}}]}) 

Then write some cljs for the sortable function (jayq makes this easy):

 (ns sortable.core (:use [jayq.core :only [$]])) (defn sortable [$elem] (.sortable $elem)) (defn disable-selection [$elem] (.disableSelection $elem)) (let [$sortable ($ :#sortable)] (sortable $sortable) (disable-selection $sortable)) 

And include the index.html file for a project like this .

There may be some way to compile jQuery libraries directly with: foreign-libs in project.clj, but I'm not sure how to do this.

EDIT: Sorry that the entire jQuery library is still in use, so it does not answer the question.

+2
source

Since I have no idea about clojurescript, I cannot give you the right solution in clojurescript, but jQuery and jQuery UI should not be so wasteful.

You can enable jQuery library using Google CDN . Many websites use this source, so the file is cached and will not load again and again. See this link.

 //you can of course easily change the version you want to use, like 1.9.1 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script 

the same could be done for jQuery UI

 <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> 

But if you just want to use the sortable jQuery UI widget, you can just use Download Builder . Just clear the Switch All checkbox under Components, and then select the Sort checkbox in the Interactions. Download the customized jQuery user interface version and all you need to enable is the jquery-ui-1.10.3.custom.min.js . Download Builder also downloads a CSS theme, but for a sortable widget I don’t see the need to enable it.

But actually incorporating the jQuery UI from the Google CDN is also a good choice. If you host libraries locally, your users should download them at least once. If you use Google, most users will not need to upload files. (if the version is no different)

Just a suggestion if nothing can help in clojurescript.

0
source

Source: https://habr.com/ru/post/1485173/


All Articles