0
votes

I am creating a plugin and made some functions to call partials on particular actions. Example:

public function onNewForm()
{
    return [
        '#main' => $this->renderPartial('@create-promise/form')
    ];
}

It succesfully loads my partial, which has additional .css and .js, however none of the additions being injected on partial load. The partial looks like this:

{% put css %}
    <link href="{{ 'assets/vendor/icheck/skins/square/aero.css'|theme }}" rel="stylesheet" />
{% endput %}

... form

{% put scripts %}
<script src="{{ 'assets/vendor/icheck/icheck.min.js'|theme }}"></script>
<script>
$(document).ready(function() {

    $('#custom_price').bind('change keypress keyup blur', function() {
        $('input[id^="price"]').attr('checked', false);
    });

});
</script>
{% endput %}

However neither css or js or script appears to be working on page - in console (inspect) they also do not seem to be included. What am I missing?

2

2 Answers

0
votes

You probably forgot to include {% styles %} in layout header:

https://octobercms.com/docs/markup/tag-styles

0
votes

Unfortunately - this will not work, put blocks does not work for ajax partials. You should include all your libraries in the onRender() function or default partial of your plugin, then use its functions wherever you need.