Timeline for Adding script conditionally
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 23, 2015 at 10:56 | history | edited | alexej_d | CC BY-SA 3.0 |
deleted 34 characters in body
|
Jun 15, 2015 at 11:08 | comment | added | alexej_d |
If you want to add jQuery programmatically you should do it this way: $page['#attached']['library'][] = 'core/jquery'; Please don't forget to vote if the answers helped you.
|
|
Jun 11, 2015 at 12:42 | comment | added | user2750995 | thanks for showing patience in answering.One last thing please do tell me if u know a way to find path of jQuery present in core(using some function of Drupal 8).Thanks. | |
Jun 11, 2015 at 11:51 | comment | added | alexej_d | You should do it as in my last edit. This hook allows you to attach a script to every page depending on your special conditions. If you add jquery as a dependency in your *.libraries.yml it will be attached automatically before your script. | |
Jun 11, 2015 at 11:49 | history | edited | alexej_d | CC BY-SA 3.0 |
suggesting a hook which would fit
|
Jun 11, 2015 at 9:57 | comment | added | user2750995 | I am trying to add both jquery and script in twig template hence I am needing to prepare variable by doing pre-processing.But then I am not able to add jQuery present in the core becoz I am having trouble in knowing its source. Any ideas? Thanks. | |
Jun 11, 2015 at 8:23 | history | edited | alexej_d | CC BY-SA 3.0 |
added 43 characters in body
|
Jun 11, 2015 at 8:22 | comment | added | alexej_d | What is the actual problem you are facing? Do you have problems choosing the right hook? Or is jquery your problem? Adding jquery as a dependency to your script is really easy, see my edit. | |
Jun 11, 2015 at 7:04 | comment | added | user2750995 | thanks for your answer but I have already seen this in the documentation and it didn't suited my requirements.Anyways do u have some ideas related to manner I have suggested above? | |
Jun 10, 2015 at 17:06 | history | answered | alexej_d | CC BY-SA 3.0 |