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

Frontend component's initialisation not clean for ajax website #31

Closed
ManUtopiK opened this issue Sep 5, 2016 · 7 comments
Closed

Frontend component's initialisation not clean for ajax website #31

ManUtopiK opened this issue Sep 5, 2016 · 7 comments

Comments

@ManUtopiK
Copy link
Contributor

With a single page application, a full ajax website or just new content added by ajax, all component's initialisation need to be reloaded for this new content. I did this by copy-paste in my theme the lines 21-81 of this file.

But this isn't DRY and not safe for future update. It will be better to wrap this component's initialisation in a function which could be call anywhere in our themes.

@andrew-worsfold
Copy link
Contributor

Fair point. SPA/AJAX sites weren't the focus during development, but there's no reason not to support them. Were you anticipating a separate function for each element type?

What is the best practice when it comes to functions of this type? Presumably they shouldn't be global scope, but accessible through the Tailor object..

@ManUtopiK
Copy link
Contributor Author

ManUtopiK commented Sep 6, 2016

Were you anticipating a separate function for each element type?

No. I took all functions for reload all elements.

Maybe it will be accessible through something like Tailor.initialize(). But there is no Tailor object in front...

andrew-worsfold added a commit that referenced this issue Sep 12, 2016
Fixed: User permission check being called too early, resulting in a warning message [GitHub #30](https://github.com/andrew-worsfold/tailor/issues/30), fuzzy spinner image [GitHub #34](https://github.com/andrew-worsfold/tailor/issues/34).
Developer: Consolidated frontend element initialization into a single function [GitHub #31](https://github.com/andrew-worsfold/tailor/issues/31), added filter for empty content placeholder text [GitHub #33](https://github.com/andrew-worsfold/tailor/issues/33).
@andrew-worsfold
Copy link
Contributor

I've updated the frontend scripts so that there is now a Tailor object. You can use the initElements function to initialize all default elements. Check out the latest commit for Tailor 1.5.5.

Does that work for you?

@ManUtopiK
Copy link
Contributor Author

Perfect! That works well.
Thanks a lot for your work!

@ManUtopiK
Copy link
Contributor Author

No, sorry, I made a mistake.
Tailor is not available as a global scope, or I missing something...

@ManUtopiK ManUtopiK reopened this Sep 15, 2016
@andrew-worsfold
Copy link
Contributor

You're right. A fix for this will be added in the next release of Tailor.

andrew-worsfold added a commit that referenced this issue Sep 22, 2016
Added: Added support for input HTML tags in content.
Fixed: Template custom post type is public [GitHub #37](https://github.com/andrew-worsfold/tailor/issues/37), frontend element initialization function is not globally accessible [GitHub #31](https://github.com/andrew-worsfold/tailor/issues/31), custom style formats defined by themes and plugins not being displayed in the editor, excerpts are displayed for password protected posts.
Developer: Added filter for control arguments by control type (e.g., colorpicker).
@ManUtopiK
Copy link
Contributor Author

It's work well this time. I got it with window.Tailor.initElements();.
Thanks.

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