Last active
December 14, 2015 07:39
-
-
Save nstadigs/5051838 to your computer and use it in GitHub Desktop.
Load javascript functionallity for dom nodes with require.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(['jquery'], function ($) { | |
var fetchAndInitModule = function () { | |
var node = $(this), | |
module = node.data('module'); | |
require([module], function (module) { | |
module.init(node); | |
}); | |
}; | |
$(function () { | |
$('[data-module]').each(fetchAndInitModule); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment