Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ui 在ClojureScript和jayq中使用jquery ui_Jquery Ui_Clojurescript - Fatal编程技术网

Jquery ui 在ClojureScript和jayq中使用jquery ui

Jquery ui 在ClojureScript和jayq中使用jquery ui,jquery-ui,clojurescript,Jquery Ui,Clojurescript,我正在尝试使用jayq和jquery.ui.sortable在页面上创建一个列表 可恶的。看着它,似乎它应该是一样的 简单到: (.sortable ($ :#sortable)) 其汇总如下: jayq.core.$.call(null, "\ufdd0'#sortable").sortable(); 并抛出: Uncaught TypeError: Cannot call method 'call' of undefined 当我试图将其包含在页面中时。有趣的是,生成的代码 当我将页面

我正在尝试使用jayq和jquery.ui.sortable在页面上创建一个列表 可恶的。看着它,似乎它应该是一样的 简单到:

(.sortable ($ :#sortable))
其汇总如下:

jayq.core.$.call(null, "\ufdd0'#sortable").sortable();
并抛出:

Uncaught TypeError: Cannot call method 'call' of undefined
当我试图将其包含在页面中时。有趣的是,生成的代码 当我将页面粘贴到js控制台时,它在页面中工作,这意味着 对我来说,在执行该行之后加载了一些必要的内容

我改了

(def cljs-options {:advanced {:externs ["externs/jquery.js"]}})

读后 ,这似乎还不够。我猜jquery.ui 修改$Prototype,但我不确定如何在 clojurescript

如果有什么不同的话,我也在使用noir和noir cljs


仔细看,jQueryUI可能需要一个手动滚动的externs文件才能使用,这可能是一项重大任务。有人能证实吗?

解决这个问题有两个不同的方面

  • 为了在高级模式下编译,我需要在externs文件中添加以下内容

    $.prototype.sortable = function (a,b) { };
    $.prototype.disableSelection = function (a,b) { };
    
  • 我使用的是noir cljs,在我的视图模板中,有以下内容:

    (:require [noir.cljs.core :as cljs])
    (:use [hiccup.page :only [include-js]])
    ...
    (cljs/include-scripts :with-jquery)  
    (include-js "/js/jquery-ui.js")
    
  • 但这永远无法工作,因为jquery ui代码需要在jquery之后但在生成的ClojureScript之前包含。解决方案是在页面中手动包含库:

    (include-js "/js/jquery.js")
    (include-js "/js/jquery-ui.js")
    (include-js "/cljs/bootstrap.js") ;; Generated
    
    (include-js "/js/jquery.js")
    (include-js "/js/jquery-ui.js")
    (include-js "/cljs/bootstrap.js") ;; Generated