I'm trying to create a theme with the UIkit 3 framework. I've added the uikit.min.js and uikit-icons.min.js files (and CSS as well), but when I try to add a modal to the page, it doesn't work.

It looks like UIkit cannot initialize the modal (or any other component).

Has somebody already implemented UIkit 3 in a Magento 2 custom theme? Is it possible to help me?

  • Have you loaded the JS via Require or via XML? – Ben Crook Mar 24 '17 at 13:34
  • I've added it through XML ([theme]/Magento_Theme/layout/default_head_blocks.xml). – user3298792 Mar 24 '17 at 13:58
  • I think this may be the problem, you should be adding JS via require and setting UiKit3 as a dependency. You can then add the dependency to other scripts. – Ben Crook Mar 24 '17 at 14:10
  • How can i implement it with requireJS? I'm not so familiar with requireJS and Magento 2. And is see a lot of different "tutorials" on internet. – user3298792 Mar 24 '17 at 14:19
  • I don't have time to provide a good answer at the moment sorry, if I get time I'll provide an answer. The official docs might help - devdocs.magento.com/guides/v2.1/javascript-dev-guide/javascript/… – Ben Crook Mar 24 '17 at 14:42

try to copy this code inside your template

require(["uikit"], function(){});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.