Public Functions in Plugin
Hi everybody,
i have a Question about public functions. My problem is, i cannot acces the function in my plugin:
- <html>
<head>
<script type="text/javascript" src="front/js/jquery-1.4.2.js"></script>
<script>
$(document).ready(function() {
(function($) {
$.fn.People = function(settings) {
var config = {
obj: this,
name: null,
getName: function() {
return this.name;
},
setName: function( newName ) {
config.name = newName;
config.obj.text(newName);
},
_init: function() {
this.setName( this.name );
}
};
if (settings) $.extend(config, settings);
config._init();
return this;
};
})(jQuery);
$('#ida').People({name: "Peter"});
$('#idb').People({name: "Isabell"});
// NEED HELP HERE WITH GLOBAL FUNCTIONS
$('#ida').setName( "Mike" );
console.log( $('#ida').getName() );
});
</script>
</head>
<body>
<div id="ida">aaa</div>
<div id="idb">bbb</div>
</body>
</html>
i want to put same public set and get methods in my object, but dont know how to...
thanks for helping