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

Initialise on keydown? #51

Open
domchristie opened this issue Nov 25, 2014 · 2 comments
Open

Initialise on keydown? #51

domchristie opened this issue Nov 25, 2014 · 2 comments

Comments

@domchristie
Copy link
Collaborator

Re: #50 Could we auto-initialise the plugin on keydown rather than on DOM ready? Something like:

$(document).on('keydown.expanding', 'textarea.expanding', function() {
  var $this = $(this);
  if (!$this.expanding('initialized')) {
    $this.expanding();

    // Prevent `keydown.expanding` from firing on this textarea(?)
    $this.off('keydown.expanding'); 
  }
});

I’m no sure off would work, but this might solve issues with .expanding textareas that are inserted into the DOM. Just a thought.

@bgrins
Copy link
Owner

bgrins commented Nov 25, 2014

Hm, something like that could probably solve the most common issue (and make the plugin just work across many more cases).

We would also need to handle the case of calling $("foo").expanding() - that's the case in #50. But maybe we could do a similar thing in that case as well?

Also, the call to off wouldn't work in this case, since it's bound on the document. But we wouldn't need to worry about preventing the event from firing again since there is a check to see if it's already initialized.

@dpDesignz
Copy link

That looks like an awesome idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants