Can jquery be used in the javascript-twig template rendering mechanism twig?

Source: Internet
Author: User
1: a template page is defined when a problem occurs in twig, and the child page inherits it. If no code can be written outside the {%} tag, an error is reported. As shown in, a piece of code is written in the tag, and the browser reports an error. for example, my jquery is introduced in the module...

1: An error occurred while using twig.


Defines a template page, and then the child page inherits it.

If no code can be written outside the {%} tag, an error is reported. As shown in, a piece of code is written in the tag, and the browser reports an error, as shown in:

I introduced jquery on the template page. When I put this code in the js file separately and introduce it in the template page, there is no problem.
What is the twig rendering mechanism? Why cannot I use $ here?
Thank you.

I just saw that the subpage can be used after jquery is directly added to the subpage. $ Can be used.
If some public resources are referenced, this will happen on the template page. how can we ensure the availability of these resources?

Reply content:

1: An error occurred while using twig.


Defines a template page, and then the child page inherits it.

If no code can be written outside the {%} tag, an error is reported. As shown in, a piece of code is written in the tag, and the browser reports an error, as shown in:

I introduced jquery on the template page. When I put this code in the js file separately and introduce it in the template page, there is no problem.
What is the twig rendering mechanism? Why cannot I use $ here?
Thank you.

I just saw that the subpage can be used after jquery is directly added to the subpage. $ Can be used.
If some public resources are referenced, this will happen on the template page. how can we ensure the availability of these resources?

When you execute js on the page
Jq has not been introduced

It has nothing to do with Twig. But because your jquery has not been loaded, reference$The code is executed.
Try to put the code in

Document. onload = function () {// below is your code}

Center.
Usewindow.onloadOr.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.