skorecky / add-clear Goto Github PK
View Code? Open in Web Editor NEWjQuery Plugin to add a (x) clear button to your input fields
Home Page: http://skorecky.github.com/Add-Clear
License: MIT License
jQuery Plugin to add a (x) clear button to your input fields
Home Page: http://skorecky.github.com/Add-Clear
License: MIT License
Hi,
I think you have an error at line 28 in the file addclear.js
It's that you have add a comma at the end of the object at this line.
https://github.com/skorecky/Add-Clear/blob/master/addclear.js#L28
Hi I'm unable to consume this package properly with bower. Can you add a bower.json pls?
Buenas, este plugin funciona con ie8? no me está andando
salduso!
I realize you don't support this add-in, but I've found it useful, so thanks! Also, I added one feature that I really needed, and thought I'd pass it back to you. Since .change() is horrible for inputs, and the alternative seems to be to use a .keyup() listener, I needed to be notified that the field had been cleared, since it doesn't generate an event. So I added onClear: null
to the options, and in the click function I added:
if (options.onClear){
options.onClear($(this).siblings("input"));
}
And now I can do this type of thing:
$("#myinput").addClear({
onClear: function(e) {
// do something
}});
Thanks again for your work!
Dave
The license comment in the minified version is a bit much. Maybe it's enough to include an URL to your license instead of including the MIT license text (just like others, e.g. jquery are doing it)?
This applies to version 2.0.5 (newest bower version). The newer minified versions don't seem to have any license header which is a bit weird too.
In package.json
it says 2.0.7
, in the file header it says 2.0.6
, with bower the hightest available version is 2.0.5
.
Putting block elements inside inline elements is against CSS standard. It's a pretty common mistake that often causes cross-browser problems.
Found while debugging https://bugs.chromium.org/p/chromium/issues/detail?id=598266
In the Boostrap 3, the inputs are often added class "form-control" with z-index = 2. That cause the error that we can't click icon X to clear text. We fixed this problem by adding z-index = 3 when tag a is created in the file addclear.js. Could you tell me better way? Sorry for my english.
Unlike #26 suggests putting <input>
inside <span>
is valid because both are inline-elements. Replacing an inline element with a <div>
like this plugin does now can lead to invalid html.
Can you add the minified js ?
thanks
If you apply addClear to multiple elements the callback is apply X times as it is bound to the close button but not in context to its instance:
$("a[href='#clear']").click(function(e) {...
This is down to...
Blocked loading mixed active content "http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"
...which simply means the browser is invoking a denial of content due to mixed https and http in the page. Remove 'http:' from the src/path for jquery.min and your demo page will provide more clicks through to Github.
what is the license of this? MIT? Please add. thx
I was playing around with your plugin for form data when I noticed a bug. When autocomplete is on such that when you load the page and the input box is already populated, pressing the 'x' button removes the pre-populated text from view, yet still allows you to submit the form as if the text had not been deleted.
Okay so not really an issue, just a public service announcement from The Curator, David Higgins (@Higgo)
-- This repo has been included in The Github Pirates' Chest.
What is this about?
The Github Pirates is a constantly updated resource for those interested in HTML5, CSS3, and JavaScript.
You should find out more about this project below:
OR, Download The Chest:
I'm interested in using add-clear in my project, but there are a couple enhancements I'd need to have first before it would work for me.
First, the clear button competes with the clear button that already exists in IE11 and Edge, creating a wonky scenario with one 'x' on top of the other. I think it'd be great if your code could disable the built-in clear button automatically (just for those browsers), but if you'd rather make that an option that defaults to false, I'd be happy with that too. Some quick research turned this up:
https://developer.mozilla.org/en-US/docs/Web/CSS/::-ms-clear
Second, if you fill the field with text, the 'x' is displayed on top of the text, which, again, looks bad. Adding padding-right of 20px seems to fix the issue nicely. Again, I'll leave it up to you if you want to make this default behavior or an option that defaults to false. There could be some interaction between this option and the first one I suggested, as the Microsoft browsers automatically add padding so their built-in clear button doesn't run into this problem.
What do you think?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.