Permalink
Browse files

Add the complete option

  • Loading branch information...
1 parent 1b5a862 commit 8e5477f909f7320499b9ad1c729c86d59643f795 @jeffkreeftmeijer jeffkreeftmeijer committed May 15, 2011
Showing with 21 additions and 8 deletions.
  1. +14 −3 README.textile
  2. +5 −4 jquery-tapir.js
  3. +2 −1 jquery-tapir.min.js
View
@@ -7,8 +7,8 @@ Check out the "live example":http://tapirgo.com/examples/jquery-plugin/index.htm
h2. Using the plugin
1. Make sure you have jQuery in your site (any version above 1.2 should work).
-2. Add the jquery-tapir.min.js to your site.
-3. Call tapir() on the element you want the results to appear in.
+2. Add the @jquery-tapir.min.js@ file to your site.
+3. Call @tapir()@ on the element you want the results to appear in (don't forget to pass your token!).
example:
@@ -28,9 +28,20 @@ example:
<script src="jquery-1.6.1.min.js"></script>
<script src="jquery-tapir.min.js"></script>
<script>
- $('#search_results').tapir({'token': '4dbfc79e3f61b05b53000011'});
+ $('#search_results').tapir({'token': '4dbfc79e3f61b05b53000021'});
</script>
</body>
</html>
</code></pre>
+
+h2. Options
+
+h3. Complete
+
+If you pass a function as a @complete@-option, your function will be executed when the search is complete and the results have been returned, right before they're appended to the page:
+
+bc. $('#search_results').tapir({
+ 'token': '4dbfc79e3f61b05b53000021',
+ 'complete' : function() { alert("I'm done searching!"); }
+});
View
@@ -6,10 +6,10 @@
init: function(options) {
el = this;
- settings = {
- token: false,
- query_param: 'query'
- };
+ settings = {
+ token: false,
+ query_param: 'query'
+ };
if (options) {
$.extend(settings, options);
@@ -21,6 +21,7 @@
$.getJSON(
'http://tapirgo.com/api/1/search.json?token=' + settings.token + '&query=' + paramValue(settings.query_param) + '&callback=?', function(data){
+ if(settings['complete']) { settings.complete() }
jeffkreeftmeijer
jeffkreeftmeijer May 15, 2011 Contributor

I might need some feedback on this. @roytomeij, @matsimitsu? :)

$.each(data, function(key, val) {
el.append('<div class="result"><h3><a href="' + val.link + '">' + val.title + '</a></h3><p>' + val.summary + '</p></div>');
});
View
Oops, something went wrong.

0 comments on commit 8e5477f

Please sign in to comment.