Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minLength option #3960

Closed
wants to merge 3 commits into from
Closed

minLength option #3960

wants to merge 3 commits into from

Conversation

pnovodvorskiy
Copy link

Added option to only start querying only after user has entered a minimum number of characters

@fat
Copy link
Member

fat commented Jun 30, 2012

this looks ok - but doesn't merge. can you update your request? thanks!

@mckramer
Copy link
Contributor

What about combining the check with the next one?
From:

if (this.$element.val().length < this.minLength) {
  return this.shown ? this.hide() : this
}   
this.query = this.$element.val()    
if (!this.query) {
 return this.shown ? this.hide() : this
}

To:

this.query = this.$element.val()
if (!this.query || this.query.length < this.minLength) {
  return this.shown ? this.hide() : this
}

Otherwise, I think it would be a welcome change, especially since 2.1 will be able to handle async lookups. So, you could limit the number of calls.

@richardp-au
Copy link

Does the data attribute for this need a capital L? If so, perhaps we could make it lowercase instead or even choose a different name. The capital would not only look a bit ugly but would confuse a lot of people and result in dozens of false bug reports.

@travisbot
Copy link

This pull request passes (merged 8017777 into fb29075).

@pnovodvorskiy
Copy link
Author

I merged the latest code from 2.1.0-wip and combined the 2 checks. I used the camel case for the naming and that's why the capital L.

@richardp-au
Copy link

I understand why you used camel case but how does this affect the data attribute?

@pnovodvorskiy
Copy link
Author

What would you prefer? min-length?

@richardp-au
Copy link

Refer to: http://blog.benpowell.co.uk/2012/03/warning-html5-data-attribute-is-case.html

So basically, HTML5 data attributes must be all lowercase and they automatically map hyphen characters (-) to camel case in the data list.

This means that in your case data-max-length is the data attribute that maps to maxLength in the JavaScript. So based on that I see no problem with what you've got.

I guess this should be noted in the docs and then it's up to @fat whether he's happy to have the two slightly differing names or whether he thinks it might confuse people too much.

@pnovodvorskiy
Copy link
Author

Thanks for the clarification. I'll wait then to see if it's accepted.

@fat fat closed this Jul 22, 2012
@fat
Copy link
Member

fat commented Jul 22, 2012

gah - super sorry, there was a bug in the unit test detection script i just ran.

@fat fat reopened this Jul 22, 2012
@@ -78,10 +79,10 @@

, lookup: function (event) {
var items

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove the spaces here? thanks!

fat added a commit that referenced this pull request Jul 22, 2012
@fat
Copy link
Member

fat commented Jul 22, 2012

just went ahead and implemented it. thanks!

@fat fat closed this Jul 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants