Giter Site home page Giter Site logo

martinf / jquery.autosize.input Goto Github PK

View Code? Open in Web Editor NEW
83.0 83.0 39.0 366 KB

A jQuery plugin which automatically resizes the width of input fields according to the content, while typing.

License: MIT License

JavaScript 54.44% TypeScript 45.56%

jquery.autosize.input's People

Contributors

anderaus 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

Watchers

 avatar  avatar  avatar  avatar

jquery.autosize.input's Issues

Getting errors on compile

I'm new to TypeScript so I might be doing something blatantly wrong but I'm currently getting errors when I compile jquery.autosize.input.ts. I'm using TypeScript version 0.9.5 on Windows 8.1. Here's what I get:

$ tsc jquery.autosize.input.ts
jquery.autosize.input.ts(48,29): error TS1005: ';' expected.
jquery.autosize.input.ts(48,30): error TS1003: Identifier expected.

Removing the brackets, results in the following:

$ tsc jquery.autosize.input.ts
jquery.autosize.input.ts(51,10): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
jquery.autosize.input.ts(56,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
jquery.autosize.input.ts(96,10): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
jquery.autosize.input.ts(99,10): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.

Very well then. Let's target ECMAScript 5:

$ tsc --target ES5 jquery.autosize.input.ts
jquery.d.ts(23,13): error TS2095: Could not find symbol 'bool'.
jquery.d.ts(25,13): error TS2095: Could not find symbol 'bool'.
jquery.d.ts(31,19): error TS2095: Could not find symbol 'bool'.
[...]
jquery.autosize.input.ts(35,5): error TS2011: Cannot convert 'JQuery' to 'string'.

What gives?

Dom pollution

I use Autosize plugin to control size of an in-place input control. I create <input> dynamically each time user clicks on editable data.

Autosize dutifully creates a mirror <span> each time โ€” and does not destroy it when an input is destroyed.

Here is a fiddle to reproduce the problem: http://jsfiddle.net/c1fxnezx/

I can contribute a fix if you'll tell me which way you want me to fix it.

autosize inputs when filled in by javascript

The inputs don't grow when filled in by javascript. Here is an example (sorry for the bad readability, I had to remove all code that prevents the actual display in this page):

.... script ...
$(document).ready(function() {
$(".autosizeInput").data('autosize-input' , {"space":8}).autosizeInput();
});

var addInputCounter = 0;
function addTextToInput()
{
    $('#autosizeInput1').val($('#autosizeInput1').val() + " --" + (++addInputCounter) + ": " + "text added here"); 
    return false;
}

.... page ....
input type="text" value="" id="autosizeInput1" class="autosizeInput" placeholder="Autosize"
a href="#" onClick="addTextToInput();"

Update input field width using any trigger

Is it possible to update the width of the input field apart from pressing 'keyup' or 'keydown' while focusing on the input field?

The thing is, I have an auto-complete plugin which allows you to select a suggestion. This suggestion then appears as text on the input field. The thing is that you have to 'focus' on the text field and then press a key for the width to 'update' to the length of the suggestion.

It is possible to run an 'update' function that I could bind with clicking on the auto-complete suggestion?

jsfiddle

does the jsfiddle work? it doesnt seem to work for me.

Add support for min/max

Would be nice to have more control over a max setting so things don't get out of control.

Input doesnt update when selecting and deleting a text

This bug happens when theres no placeholder, so the value is 'undefined'.

bug

I have a solution for this. When the event is triggered, I put a empty string in case that the placeholder is undefined.

I will send you a pull request in a couple of hours

How to pass options when calling function.

I tried

$('input[type="text"]').autosizeInput( {space: 1} )

But it doesn't work.

I can't find an example - except for the one using data attributes - anywhere.

Thanks.

not working in wordpress

hello when i try to get this script work on wordpress i get error:

var Plugins;
(function (Plugins) {
var AutosizeInput = (function () {
function AutosizeInput(input, options) {
var _this = this;
Uncaught TypeError: Property '$' of object [object Object] is not a function
this._options = options;

i use
jQuery(document).ready(function($){
$(".some class").autosizeInput();
});

thanks for help

Fit Parent Container Width

Hello Martin,

One of the use-case i was thinking of.. I have parent div of width:200px; and when I use autosize input ..it keep on growing beyond 200px. Any suggestions?
I was thinking of:

  1. Find the parent element where the input is attached and get the width
  2. pass maxWidth options to constructor

http://jsfiddle.net/mJMpw/1280/

Thanks

Bubble Up?

I have quite a few inputs in a project of mine that are added to the DOM based on certain events (click here to add a new field basically), and the DOM is injected by jQuery. All of those inputs contain data-elastic-input still, but they don't become elastic.

Near the top of $(document).ready, I have:

$("input[data-elastic-input]").autosizeInput();

And that doesn't catch it. I have also tried doing that same line on the event that the new DOM is added to catch it - even with a specific selector to the new inputs.

Thoughts on how I can resolve this?

Thanks!

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.