I have a bunch of methods that make use of jquery to basically generate a list view. The problem is I need to use this thing multiple times, so I need to make it reusable.
- Should I just write a jquery plugin?
- Should I write a non-jquery plugin Js Object (like a class in non-prototype languages) and just create instances as I need?
The primary concern is how to handle the case where I need to modify one of the methods that make up my plugin. So my reusable component has to be modifyable. I know how to do it with approach 2, not sure how to do it with approach 1.
edit -- to give an idea of what this is: its basically a list view plugin. So, it takes an xhr response, parses the xml/json inside, and adds a list of divs to a containing div. I was surprised I couldn't find an existing plugin to do this. Other js frameworks have this.
The reason it needs to be extensible is, it might have to deal with xml/json in the response -- so the handling of response is different. It might have to deal with outputting different templates for each response. etc...