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

Script not working on dynamically inserted elements #54

Open
crisbeto opened this issue Nov 16, 2013 · 4 comments
Open

Script not working on dynamically inserted elements #54

crisbeto opened this issue Nov 16, 2013 · 4 comments

Comments

@crisbeto
Copy link

Elements that are inserted through JavaScript don't get the placeholder functionality.
It works when elements are added with jQuery, however it doesn't work on elements added through AngularJS.

Also tried triggering it manually with Placeholders.enable(element); but it doesn't work.

@jamesallardice
Copy link
Owner

Thanks for reporting this. Can you update the issue with a simple example? That would make it easier for me to debug. I have never noticed any problems with dynamically created elements, but I only actually test ones created with native DOM methods rather than any libraries.

@crisbeto
Copy link
Author

After a bit of fiddling with the script I managed to get it to insert the placeholder text when the element is created, however this leaves the possibility of the placeholder text being submitted to the database. In the end I decided to write my own( more angular-friendly) implementation which doesn't interfere with the data bindings. I can post my code if you want. (it involves a dummy element that holds the placeholder and passes the focus to the real one)

@RyanGladstone
Copy link

Hello crisbeto,

I'd be interested in seeing your solution if you wouldn't mind as I ran into the same problem.

Thanks,
Ryan

@crisbeto
Copy link
Author

Hope it helps: https://gist.github.com/crisbeto/7698305

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