Code Monkey home page Code Monkey logo

jquery-clearsearch's Introduction

jquery-clearsearch's People

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

Watchers

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

jquery-clearsearch's Issues

If the input resizes, the clear button doesn't update position

In a responsive form the controls will certainly resize. So it'd be great if the clear button moved with the control.
For a quick fix I added a call to update() but had to run it off the window.resize event.
Using a timeout made it run smooth.

	...
	triggerBtn();

	$(window).resize(()=> {
		if (this.resizeTO)
			clearTimeout(this.resizeTO);
		this.resizeTO = setTimeout(()=> {
			update();
		}, 500);
	});
});

I just appened this to the end of the jq object.

Suggestion

The wrapper div put around the input element can break layouts that depend on the input staying as inline. Suggest adding 'inline-block' to the style declaration on the wrapper div. This seems to work for my particular instance.

diff:

[sdavied@linuxweb js]$ svn diff jquery-clearsearch.js
Index: jquery-clearsearch.js
===================================================================
--- jquery-clearsearch.js       (revision 359)
+++ jquery-clearsearch.js       (working copy)
@@ -43,7 +43,7 @@
                                                divClass = settings.clearClass + '_div';

                                        if (!$this.parent().hasClass(divClass)) {
-                                               $this.wrap('<div style="position: relative;" class="'
+                                               $this.wrap('<div style="display: inline-block; position: relative;" class="'
                                                        + divClass + '">' + $this.html() + '</div>');
                                                $this.after('<a style="position: absolute; cursor: pointer;" class="'
                                                        + settings.clearClass + '">' + settings.linkText + '</a>');

Edit: posted the correct diff (old one applied to the anchor rather than div - oversight on my part)

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.