0

I am trying to use Bootstrap datetimepicker in my clojurescript project as below :

(.datetimepicker (js/$ "#dateid")

but am ending up with Uncaught TypeError for datetimepicker function.

Error: Uncaught TypeError: $(...).Bk is not a function

On some analysis I found a reason for this may be the optimization done by google closure compiler. A possible resolution for this is by creating extern.js file and adding function names so that the names are not optimized in the closure compiler .

I tried to modify my extern.js but it doesnt help My extern.js looks like this .

 var $ = function (arg1, arg2) {};
    $.prototype.val = function(arg1) {};
    var selectpicker = function() {};
    $.datetimepicker = function(arg1) {};
    var datetimepicker = function() {};
                      

I am still getting the same error .

I need to know whats wrong with my extern.js so that i can avoid the bootstrap-datetimepicker functions not getting optimized which causes Unknown Type exception

akond
  • 15,865
  • 4
  • 35
  • 55
HPK
  • 11
  • 1

1 Answers1

0

The google closure compiles the clojurescript's js files to an optimized file. But this also causes problems when we try to use js libraries and do not use extern to map the names . so the function name Bk is an optimised name , but it should have got mapped using the extern.js file . I am not sure how to do that exactly .

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 01 '21 at 14:16
  • Use cljsjs library to resolve the issue. – developerAtHeart Feb 07 '22 at 10:36