2

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

3 Answers 3

4

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);
Sign up to request clarification or add additional context in comments.

Comments

1

jQuery's plugin authoring is a great starting point.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.