I am working on an ajaxified paginator plugin using jquery. here is my code:
$.paginator = function(options) { this.options = { 'url': null, 'replace_id': null, 'total_items': 0, 'items_per_page': 10, 'total_pages': 0, 'current_page': 1, 'new_page': 1, 'navigator_type': 'numbers' }; $.extend(this.options, options); this.options.total_pages = this.options.total_items / this.options.items_per_page; this.go_to_page(this.options.current_page); }; $.paginator.prototype = { go_to_page: function(number) { this.options.new_page = number; reload_content(); }, get_page: function(way) { if(way === 'next') { this.options.new_page = this.options.current_page + 1; } else if('previous') { this.options.new_page = this.options.current_page - 1; } reload_content(); }, next_page: function() { get_page('next'); }, previous_page: function() { get_page('previous'); }, navigator: function() { var x = 0; var navigation = '<div id="paginator_navigation">'; for(x = 1; x <= this.options.total_pages; x++) { navigation += ' ' + x + ' '; } navigation += '</div>'; alert(navigation); $('#' + this.options.replace_id).append(navigation); }, reload_content: function() { $('#' + this.options.replace_id).empty(); //add loading screen code $('#' + this.options.replace_id).load ( this.options.url, { 'total_items': this.options.total_items, 'items_per_page': this.options.items_per_page, 'current_page': this.options.current_page, 'new_page': this.options.new_page }, function() { //remove loading screen code } ); //update internal variables this.options.current_page = this.options.new_page navigator(); } }; however when I do: var paginator = $.paginator( { 'url': 'page_test.php', 'replace_id': 'paginator_test', 'total_items': 10, 'items_per_page': 2 }); I get this.go_to_page in not a function. I figured that I could call that function there even though the function is declared later since don't call the "constructor" function until all the code is loaded anyway but I guess not. Any help on making this work since I do want to be able load the paginator once it is declared. -- View this message in context: http://www.nabble.com/my-plugin-not-working-tp14419521s27240p14419521.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.