-
Notifications
You must be signed in to change notification settings - Fork 38
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
Show default click trigger classes in the popup editor or click trigger. #584
Comments
@danieliser We added this explainer in 1.11 to the click trigger settings: Is that what this issue is referring to or was there something more you wanted to do here? |
@fpcorso - Yea that should suffice. That said now that I've reread that description just now (I did approve it, so I missed it before), I wonder why you chose name over ID. Name's change over time breaking the link. |
@danieliser Yeah, I had copied in the text that was originally near the name field which appears to not have had the ID class with it. Definitely makes sense to use that here. We'll try to switch that out in the next update before closing this then. |
@danieliser That section is added in Triggers.php where I can't easily retrieve the ID for the current popup being edited. I temporarily switched to We could add an empty HTML element there, such as Can you think of a more efficient way to do it? |
Yea I would use a placeholder and JS to swap it based on the post_ID field value. |
@danieliser Set the field to have a span placeholder and have some JS to swap it. However, the click settings template for the field gets regenerated every time you add a trigger. So, when you click the add trigger button, it regenerates the template, thus showing the placeholder instead of the new value I swapped it with. I'm assuming this is done to populate the fields with the correct values but it makes it difficult to swap out the placeholder now. Alternatively, I could swap out the placeholder when the click trigger settings open instead. But, there doesn't seem to be a good place to do that in the triggers.js file. |
…ID values Also includes some code qualtiy improvements from ESLint and PHPCS. Issue #584
@fpcorso Try pumInit JS event. I would do it like this for now.
And inside the above JS event something like this.
Will fire off every time a form is re-rendered. |
@danieliser That code doesn't work. The issue wasn't finding or changing the text. It's that the plugin completely recreates the template when the trigger is being added. Running that code above changes the span text correctly during pageload or puminit. But, as soon as the trigger button is clicked, the template is overwritten to use the default empty span again. This occurs during the We could add some code after that to change the span. The onsubmit event handler is added after that too so it might make sense to add code affecting the trigger settings modal there. |
@fpcorso Sorry your right, I was mistaken, it seem the proper event name is pum_init for some reason: https://github.com/PopupMaker/Popup-Maker/blob/master/assets/js/src/admin/popup-editor/plugins/triggers.js#L304 That event is triggered on every redraw of a form intentionally. Because of that you must "initialize" elements in a detectable way. That is why it uses But this way if the form is redrawn, it will Now, you may want to use a different designation class than |
@danieliser Ah, I thought the pum_init type events only fire when all of PM is initialized. I didn't realize we also have one firing each time after the form modal is recreated. I'll need to play with that to see if I can find it and work with that. Where is that called? I didn't see it in the modal or template JS files which are the only thing called during that form method? |
@fpcorso Check the render method for forms: https://github.com/PopupMaker/Popup-Maker/blob/master/assets/js/src/admin/general/plugins/forms.js#L484 It triggers on the form itself, but like I mentioned in my PR review today, events bubble up to document, so we catch it there. |
@danieliser I don't think we ever call any methods from forms.js here. The method I linked to ( Here is where the modal gets created in triggers.js: Which calls templates.modal which is just a quick wrapper for templates.render which only calls All that the modals.reload method does is remove the old HTML and appends the new HTML: https://github.com/PopupMaker/Popup-Maker/blob/master/assets/js/src/admin/general/plugins/modals.js#L140 That said, at the very end of that method, it triggers a Unfortunately, I can't get it to work for some reason. |
@danieliser Nevermind that last paragraph. I had a type in my code 🤦♂️ |
@danieliser So, it does work, but |
@fpcorso Its effecient as long as your code properly bails early. That is what the Again make a new -initialized class for this. |
Set up the popup-{popup-ID} to be dynamically replaced with the actual popup ID to make it easier for copying and pasting. Issue #584
@danieliser Got this working correctly now: |
No description provided.
The text was updated successfully, but these errors were encountered: