Created
March 21, 2010 14:01
-
-
Save cange/339316 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Mashup of jquery.pyte and jquery.customdata for Component-based plugins | |
* load classes from JavaScript. | |
* @see http://github.com/psyk/jquery-pyte | |
* @see http://github.com/ubilabs/jquery-customdata | |
* | |
* @example | |
* <!-- DOM structure --> | |
* <div id="myComponent" data-jsc="module.MyComponent">component content</div> | |
* | |
* //JavaScript module/MyComponent.js | |
* module.MyComponent = $.inherit({ | |
* __constructor: function(){ | |
* your components source | |
* } | |
* }); | |
*/ | |
$.extend({ | |
autoLoad: function () { | |
$.require('jquery.customdata.js'); | |
$(":customdata").each(function () { | |
var jsClass = $(this).customdata().jsc; | |
if(jsClass.length > 0) { | |
$.require(jsClass); | |
window.eval(jsClass.split(/.*\./)[1] + ' = new ' + jsClass); | |
} | |
}) | |
} | |
}); | |
$.autoLoad(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment