Skip to content

2.1 : script text/x-magento-init not working in adminhtml #5514

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

Closed
kanduvisla opened this issue Jul 7, 2016 · 1 comment
Closed

2.1 : script text/x-magento-init not working in adminhtml #5514

kanduvisla opened this issue Jul 7, 2016 · 1 comment

Comments

@kanduvisla
Copy link
Contributor

kanduvisla commented Jul 7, 2016

I have added some JavaScript functionality to the backend, and for that I used <script type="text/x-magento-init"></script>. This worked fine in 2.0.7, but in 2.1 this stopped working.

I've added it with after_element_html when creating the form:

$fieldset->addField(
    'my_field',
    'textarea',
    [
        'name' => 'my_field',
        'label' => __('My Field'),
        'title' => __('My Field'),
        'after_element_html' => '(some HTML, ending with the script-tag)'
    ]
);

This worked fine in 2.0.7, but in 2.1 this stopped working. When I look at the source, I simply see the raw <script>-tag there, that otherwise would have been replaced.

Now I assume my approach (misusing after_element_html to insert an entire HTML-blob) isn't the most elegant, but it worked. Until the 2.1 update.

Can anyone point me in the right direction why this stopped working or how I should implement it otherwise?

a small footnote: the html included and the JavaScript are all knockout-based. Could that have something to do with it? Since knockout is now already throwing errors on my custom html, which makes sense of course.

@kanduvisla
Copy link
Contributor Author

Turns out I was implementing knockout all wrong. For anyone encountering the same problem: read these articles:

mmansoor-magento pushed a commit that referenced this issue Oct 15, 2020
[TSG] TESTs Fixes for 2.3 (pr121) (2.3-develop)
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

1 participant