Search code examples
drupal-8

How can I override core misc js in drupal 8


I have a problem with dialog in drupal 8, and I found a place that make me stuck. There is a code in this file not work as my expected. Please see the image

enter image description here

I just want to do the simple thing is comment the line out like below: enter image description here

I can't do this because this is core file. So I want to override this file or this function only.

I trying to use libraries-override but no hope. This is my code, I am newbie so this code may have mistake or wrong. enter image description here

"capital" is my theme, not module

below is my theme structure:

enter image description here

Please help... I googled this issue for long time.


Solution

  • I have solved it by myself:

    Step 1: clone core js to your theme js like this:

    enter image description here

    Step 2: modify template library ([your-theme-name].libraries.yml) Declare core file your need to add to your theme

    enter image description here

    Step 3: disable core files using your theme info file ([your-theme-name].info.yml) and add your files as library:

    enter image description here

    That's it :) Any better idea? please suggest me more.