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

Cannot run Vue components in the addon (except in the fieldtype) #586

Closed
lesaff opened this Issue Apr 7, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@lesaff

lesaff commented Apr 7, 2016

Steps to reproduce

  1. Create a simple widget addon (just for simplicity purpose, can be any addon with cp page)
  2. Add js to the bottom of the cp page (for now, this is the only way to do it #544)
  3. Instantiate Vue.component('your-component', yourComponent);. Do something like alert() or something that gives you instant feedback
  4. Add the appropriate tag to your widget blade view

Expected behaviour

Alert window should pop up

Actual behaviour

CP strips out all v- and ignore the newly added component

Server configuration

Operating system: El Capitan [latest]

Web server: MAMP Pro 3.5

PHP version: 7.x

Statamic version: 2.0.0

Updated from an older Statamic or fresh install: updated from b20

List of installed addons:
a bunch of custom-made addons

Notes
No JS error

@lesaff

This comment has been minimized.

lesaff commented Apr 7, 2016

I found out why my addon vue component wasn't parsed by the cp. Initially, I loaded my addon js after jabbascripts. Turns out, it has to be loaded before jabbascripts

Not sure whether I should close this or leave it for others?

@lesaff

This comment has been minimized.

lesaff commented Apr 7, 2016

my scripts.blade.php looks like this now

<script src="{{ cp_resource_url('js/johnny-deps.js') }}?v={{ STATAMIC_VERSION }}"></script>
<script src="{{ cp_resource_url('js/cp.js') }}?v={{ STATAMIC_VERSION }}"></script>
{!! $fieldtype_js !!}
{!! $layout_foot !!}
<script src="{{ cp_resource_url('js/jabbascripts.js') }}?v={{ STATAMIC_VERSION }}"></script>
@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Apr 21, 2016

For the next release, any YourAddon/resources/assets/js/scripts.js will get added to the cp automatically. No need for any events.

Write JS directly into there, or adjust your build process to output that file. If it exists, it'll get loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment