tags:

views:

52

answers:

1

hi.i wrote a jquery function and now i want to use it as a plugin so i could use that more than 1 place.the code lookes like this:

    function loadTable(){
    $.post("includes/action.php", {action: "gettable"}, function(html){
        $("#tblstudents tbody").html(html);
        $("#tblstudents")
            .tablesorter({widthFixed: false, widgets: ['zebra'], sortList: [[0,0]]})
            .tablesorterPager({container: $("#pager")})
            .tablesorterFilter({filterContainer: $("#filter-box"), filterClearContainer: $("#filter-clear-button")});
    });
}

And I want it have functions for setting "includes/action.php" and "gettable" in $.post function and $("#pager") ,$("#filter-box") and $("#filter-clear-button") from $("#tblstudents").Can anyone help me?

+3  A: 

you should check this link: http://docs.jquery.com/Plugins/Authoring

or here you can find a step by step tutorial: http://www.queness.com/post/112/a-really-simple-jquery-plugin-tutorial it explains how you can define your own options for your plugins.

meo
+1, but I'd include this tutorial as well ;) http://www.learningjquery.com/2007/10/a-plugin-development-pattern
fudgey