Giter Site home page Giter Site logo

soulmate.js's Introduction

soulmate.js

Soulmate.js is a jQuery plugin front-end for soulmate, an excellent auto-suggestion gem built for speed on sinatra and redis. Together, they provide lightning-fast plug-n-play auto-suggestion. See soulmate on github for more details on the back-end interface.

Note: This plugin is not affiliated with the soulmate gem or its authors. The name is merely a knock-off.

Demo

Soulmate.js is inspired by the excellent autocompletion interface used on seatgeek.com. It works and feels very similar, although the implementation is entirely original.

The demo directory in the source provides an example usage and styling of the plugin. It does not supply a back-end, however, so you will have to set up soulmate and point the demo to it.

Features

  • Well tested: Ridiculous spec coverage using Jasmine.
  • Clean markup: Renders a clean and semantic markup structure that is easy to style.
  • Speed: Minimizes requests by maintaining a list of queries with no suggestions. No additional requests are made when a user keeps typing on an empty query.
  • Cross-domain compatible: Uses jsonp to accommodate backends on separate domain (which is a good practice since it allows the auto-suggest system to get overwhelmed without affecting the main site).
  • Customizable behaviour: Customized rendering of suggestions through a callback that provides all stored data for that suggestion. Customized suggestion selection behaviour through a callback.
  • Adaptable: A modular, object-oriented design, that is meant to be very easy to adapt and modify.

Usage

First, setup an instance of soulmate. Then, grab src/compiled/jquery.soulmate.js and place it in your project. Finally, do something like the following (or follow the example in the demo directory):

index.html

...
<script type="text/javascript" src="jquery.soulmate.js">
<script type="text/javascript" src="main.js">
...
<input id="search-input" type="text" name="q" value="" autocomplete="off"/>

main.js

...
// Define the rendering and selecting behaviour for suggestions.
render = function(term, data, type){ return term; }
select = function(term, data, type){ console.log("Selected " + term); }

// Make the input field autosuggest-y.
$('#search-input').soulmate({
  url:            'http://soulmate.YOUR-DOMAIN.com/search',
  types:          ['type1', 'type2', 'type3', 'type4'],
  renderCallback: render,
  selectCallback: select,
  minQueryLength: 2,
  maxResults:     5
});
...

For more information, see the specifications in the spec/ directory.

Running Specs

Soulmate.js is covered by Jasmine and Jasmine-JQuery specs. See the spec/ directory to browse the specifications.

To run the specs, simply open spec/spec_runner.html in your browser.

soulmate.js's People

Contributors

mcrowe avatar adamalbrecht avatar aroop avatar

Watchers

Eliot Shepard avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.