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

Moving InputfieldPageAutocomplete's "delete item" click handler into init method? #1183

Closed
apeisa opened this issue May 20, 2015 · 3 comments

Comments

@apeisa
Copy link
Contributor

apeisa commented May 20, 2015

For some reason click handler for removing rows is initialized on document ready instead of init method. In normal pw admin use this doesn't matter, but we are building product where we are loading inputfields through ajax. Moving handler from row https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.js#L247 inside init method in same file naturally fixes the problem and should be fully backwards compatible solution. $(document).ready(function() wouldn't be necessary at all.

Any hope to get that moved?

@apeisa apeisa changed the title InputfieldPageAutocomplete moving "delete item" click handler into init method Moving InputfieldPageAutocomplete's "delete item" click handler into init method? May 20, 2015
@ryancramerdesign
Copy link
Owner

I think we could do that, though not 100% sure it would be fully backwards compatible. I look at it and think "why is that in document.ready rather than in the dedicated class?" When I wrote the code there, it's always possible I was just being dumb, but it's also possible there was a good reason. So before we move it, I'd want to see if there's some way to make it work with what you are trying to do there. For instance, what if we changed this:

$(".InputfieldPageAutocomplete ol").on('click', 'a.itemRemove', function() {

To this?

$(document).on('click', '.InputfieldPageAutocomplete a.itemRemove', function() {

@apeisa
Copy link
Contributor Author

apeisa commented Jun 26, 2015

Sorry for the late reply. This fixes it also. While I have hard time seeing why moving the handler into init might cause problems, I'll trust your instinct and would be very happy with the change you proposed.

@apeisa
Copy link
Contributor Author

apeisa commented Jul 5, 2015

I see this is implemented already, so closing this.

@apeisa apeisa closed this as completed Jul 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants