Reputation: 7972
Here's my problem: I've got this nice Office Minibar implementation which I want to use on my project. However, I need to apply the Jquery code to dynamically created textarea elements, hence requiring the use of
$("#textarea_id").minibar(); //minibar() applies the minibar to the selected textarea element
However, i'm at a complete loss on how to do it. Any help would be great appreciated. The Minibar coding is fairly simple:
http://www.jankoatwarpspeed.com/post/2010/05/23/microsoft-office-minibar-jQuery-CSS3.aspx
Upvotes: 2
Views: 122
Reputation: 59
I also agree that the Plugin Authoring tool is a good start.
Also there is a Jquery Plugin Skeleton that provides a commonly used plugin pattern.
I noticed that in your code you have static ids and markup. It may be better to create these elements dynamically so people that use your plugin don't have to add them and there are no id or class name conflicts.
Upvotes: 1
Reputation: 359776
Start out reading the jQuery plugin authoring guide. It does a really good job of walking you through things. If you want to cut to the chase, read the summary and best practices section.
Basically, it'll look like this:
(function($){
$.fn.minibar = function () {
// minibar initialization code here
};
})(jQuery);
Upvotes: 4