Skip to content

Commit

Permalink
adding afterRender to Renderer.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbuthay committed Jul 17, 2011
1 parent c20266b commit 1ae6cf2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion jquery.indextank.renderer.js
Expand Up @@ -30,6 +30,7 @@
r.appendTo(base.$el);
});
base.$el.css({opacity: 1});
base.options.afterRender(base.$el);
});

base.$el.bind("Indextank.AjaxSearch.noResults", function(e, query) {
Expand Down Expand Up @@ -59,7 +60,11 @@
.append( $("<span></span>").addClass("description").html(item.snippet_text || item.text) );
},
setupContainer: function($el){
$el.html("");
$el.html("");
},
afterRender: function($el) {
// do nothing. You may want to re arrange items,
// append some sort of legend, zebra items, you name it.
}
};

Expand Down
13 changes: 13 additions & 0 deletions tests/unit/jquery.indextank.renderer.js
Expand Up @@ -15,6 +15,10 @@ module("Module Renderer", {
this.okSetupContainer = function() {
ok(true, "okSetupContainer");
};

this.okAfterRender = function() {
ok(true, "okAfterRender");
};
},
teardown: function() {
}
Expand All @@ -28,6 +32,15 @@ test( "check that setupContainer function gets called once for each search", fun
r.trigger("Indextank.AjaxSearch.success", this.resultSet);
});

test( "check that afterRender function gets called once for each search", function() {
expect(3);
r = $("<div/>").indextank_Renderer({afterRender:this.okAfterRender, format:this.dummyFmt});
r.trigger("Indextank.AjaxSearch.success", this.resultSet);
r.trigger("Indextank.AjaxSearch.success", this.resultSet);
r.trigger("Indextank.AjaxSearch.success", this.resultSet);
});


test( "check it calls format function for each result", function() {
expect(4);

Expand Down

0 comments on commit 1ae6cf2

Please sign in to comment.