GithubHelp home page GithubHelp logo

jstayton / jquery-marcopolo Goto Github PK

View Code? Open in Web Editor NEW
179.0 179.0 28.0 430 KB

A jQuery autocomplete plugin for the discerning developer.

Home Page: http://jstayton.github.io/jquery-marcopolo

License: MIT License

JavaScript 96.55% CSS 2.81% HTML 0.64%

jquery-marcopolo's Introduction

Justin Stayton

——— Indie Hacking

Lateral.run     Empower your customers to extend your app, not your feature backlog     Node.js Vue.js Tailwind CSS PostgreSQL AWS

——— Open Source

piratepx     Just a little analytics insight for your personal or indie project     Node.js Vue.js Tailwind CSS PostgreSQL 11ty

QueryQL     Filtering, sorting, and pagination for your Node.js REST API     Node.js

Suri     Your own link shortener that's easily deployed as a static site (for free)     11ty piratepx

jquery-marcopolo's People

Contributors

callmevlad avatar firedev avatar hobnob avatar jstayton avatar lwe avatar sammcd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-marcopolo's Issues

Clearing the cache

I'm using this to query a database for a list of orders. One of my options is to delete the order. Once the order is deleted I don't want it to show in the list any more. However nothing I seem to do makes that happen. Setting the cache to 'false', or 0 doesn't affect it. Refreshing the page doesn't affect it. How do I force marcopolo to refresh it's cache?

Error on init only in non-minified version?

I have our includes set up to only use minified versions in production, and I'm getting this error only in the non-minified version:

Uncaught TypeError: Object function ( selector, context ) {
        // The jQuery object is actually just the init constructor 'enhanced'
        return new jQuery.fn.init( selector, context, rootjQuery );
    } has no method 'widget'

IN
jquery.marcopolo.js:21

FROM
(anonymous function)jquery.marcopolo.js:21
(anonymous function)jquery.marcopolo.js:997

Hide result numbers

Hey,Thank you in advance for your good plugin
but I need to hide numbers in search result OL
How i can do it ?

Localization

Hi,
Is it possible to add Localization Marcopolo?
I can definitely add Portuguese and Spanish locales if implemented.
Thanks for this great project.
cheers

json validity question

hey, thanks so much for this plugin, it really seems to be a well thought out approach to the autocompletion pattern. i know this isn't support so feel free to delete, however ....

in the documentation, the json reads :
first_name: 'James',
last_name: 'Butler',
profile_url: '/users/78749',

however, i'm pulling my json from a mssql database, giving it a utf-8 header and outputting valid json as

"ID": 1,
"Department": "Assembly",
"Manager": "eh",

is this discrepancy between the json and string handling with quotes the reason why mp is connecting to the url, sending the param but not being sent back any data?

my js:

$('#customer').marcoPolo({
url: '../modules/quality-control-dependencies/quality-control-live-search-departments.php',
formatItem: function (data, $item) { 
return data.department;
},
onSelect: function (data, $item) {
this.val(data.department);
},
minChars: 3
});

No way to use [home] or [end] keys to navigate/select text

It's good, that [Home] and [End] keys are used in the plugin to jump through a results list.
But some users, as me, used to use them to navigate text.

It'll be great if I can at least use [Shift] + [Home/End] to select typed text.
And, even better, to also use for example [Ctrl / Command] + [Home/End] to navigate text,
or, may be, vise versa -- lets leave everything native, but preceded by [Ctrl / Command] these keys would have "special" behaviour -- jumping through a results list.

Thanks

'required' feature remains after destroy

Hi Justin,

I noticed that the 'required' feature seems to remain even after I destroy MarcoPolo on a specific input field. I.e. when I leave the input field, the input is cleared (as I did not select a value).

Currently, I have to do the following to fix it:

$('#authorName').marcoPolo('option', 'required', false);
$("#authorName").marcoPolo('destroy');

Cheers,
Josef

Being able use a function instead of a url

The function would then return the results object to marcopolo. Can't tell if this is already supported, but I don't see it mentioned anywhere.

Another thing that could be nice, is to just pass it an object directly if the options are static and minimal, and save a request.

Curious to know if these features are being considered, and when they might be added. Eager to try the plugin.

Thanks!

Support for results sections.

Are there any plans for addding support to sectioned results? Like facebook search, for example (people, places, etc..).

Or is there currently any way of achieving this?

Is there a way to supply html to MarcoPolo?

Hi,

When using Marcopolo with Rails I find it a bit annoying that I can't render html and have to keep twice the templates for rendering items in Marcopolo and on the page.

Is there a way to accept rendered collection in html form somehow?

Querying on part of input field (an editable div, actually)

Hi -

I've attached marcopolo to an editable div and it seems to work fine, as long as I fire the search event on keyup within the div.

Now, I'm also querying on a selected part of the div's content when firing the search event, so I'm supplying the (adapted) query string to the search function.

Pseudocode:
document.ready()
$element.marcoPolo(options...)
$element.bind("keyup") {
var qs = do_some_stuff_with_input_field_data
$element.marcoPolo("search", qs)
}

Now, one strange thing is that when I fire the search event, the querystring used is what is in the qs variable, but the latest character is chopped off. (console.log(qs) right before firing search prints out the correct value of qs).

I've disabled caching, set the delay to 1ms, but to no avail. I think it has something to do with the "keyup" event binding clashing with that of the marcoPolo library.

Thanks, and keep up the great work!

Marco Polo doesn't show Empty Results in IE8

Similar to #13, but the difference is – current version actually shows results, but when there are no results formatNoResults doesn't seem to appear in IE8.

#mp_search_list stays empty in IE.

Features

I'm really enjoying the plug-in, great work!! I have a couple of use cases that appear to be not supported...it seems your not actively working on it, so I'm looking for some guidance on how to implement the following:

  1. Limit the selection to n. My use case for example prevents more than one item to be selected.

  2. I'd like to present a grouping of list items (based on an attribute in the results). example:

Products
Hose
House

People
Harry
Harold

Breaking with jQuery 1.8.x

I get javascript breaking when I upgrade to 1.8.X. The issue is with the visible selector for some reason, it breaks on the line:

        if (!self.focusReal && self.$list.is(':visible')) {

Can't seem to get more information, but it is something to do with the Sizzle engine. Sorry for the lack of info, about to launch a project!

formatNoResults not showing

This is the code I use for autocomplete. Suggested autocomplete works, but when there are no matches, I do not see No results for <query term>

$('#visitor_company_name').marcoPolo({
    url: '/server/control.php',
    data: {
      mode: 'visit_company_name'
    },
    formatItem: function(data, $item) {
      return data.visitor_company_name;
    },
    onSelect: function(selected_company, $item) {
      $("#visitor_company_name").val(selected_company.visitor_company_name);
    },
    param: 'visitor_company_name',
    minChars: 1,
    delay: 500, // only start autocomplete query after 0.5 seconds
    required: false
  });

This is the HTML element from Chrome Inspector

    Even when I explicitly declare formatNoResults in the code

    formatNoResults: function(q, $item) {
          return '<em>No companies with name <strong>' + q + '</strong>.</em>';
        },
    

    I still do not see the results element. The only difference is the CSS style is changed from display: none to display: block

      Am I missing anything? I use the exact code for 2 other text input fields and they work fine.

      Add support for TAB key selection

      [NOTE: From email correspondence.]

      Justin,

      Sorry to bother you and thanks for writing such a great jQuery plugin.
      I have a quick question if you have the time:

      In order to select an item from a marcopolo drop down list i have to either:

      1. arrow down to an item in the list and press enter.
      2. mouse over and click an item in the list.

      Q: How can I add a third way to select an item such that the user can
      arrow down to select an item and then press the TAB key to jump to the
      next field and select the highlighted value. At present the currently
      highlighted item is not stored in the field's value if you TAB away as
      opposed to pressing the ENTER key.

      Thanks,

      Brady

      Make a GET request on mouse input.

      Hello there!

      My javascript isn't great so I realize this may well be a trivial issue. But is it possible for a search to be made when you paste in to the search box via the mouse? At the moment it seems as thought a GET request is only fired on keyboard input.

      I'm using the default code in the README example. How can I modify this so that a search is fired when text is pasted in to the element via the mouse (as well as with keyboard input)?

      $('#userSearch').marcoPolo({
        url: '/users/search',
        formatItem: function (data, $item) {
          return data.first_name + ' ' + data.last_name;
        },
        onSelect: function (data, $item) {
          window.location = data.profile_url;
        }
      });
      

      Cache invalidate

      Hello, can you implement an API function for cache invalidation?

      Option to bind the result list to another element

      Hey there!
      Because of variuos reasons, my input field is surrounded by a div with overflow: hidden. When the result get displayed, the ol gets trapped inside the div.
      Is there a way to tell marcopolo to bind the result ol to another element? Maybe an option which expects a selector?

      local json data

      Is there an option for providing the result list locally instead of requiring GET requests? i made a quick hack to get that functionality but if its already there maybe i'm missing something?

      Cant set initial value

      i cant set initial value even if i use

      this is my code
      $('#Cor').marcoPolo({
      data: {
      limit: 10

      },

      url: 'ajax_actions.php?',
      formatItem: function (data, $item) {
      return data.info +' Cod Cor:'+ data.value;
      },
      minChars: 3,
      formatMinChars : function(minChars, $item) {
      return 'Introduceti minim ' + minChars + ' caractere.';
      },
      onSelect: function (data, $item, initial) {
      this.val(data.info);
      }
      });
      Hope you can help me
      thank you

      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.