1

I am using a Javascript plugin (several lines of code) that from times to times is released a new version.

For this reason I am trying to avoid changing the original source code in order to affect my wishes.

One way that is "half" working for me is to find all the elements that are using a specific CSS class (or group of classes) and them I am removing it (or do something else with them) in order to do what I want.

The part that is not working is the "trigger/event" to process this action. During the execution of this plugin new elements are created and removed and once again I am having "wrong" entries once again.

My question: How can I "catch" all the elements that are "from a moment to the other" using the CSS class XXX? and then execute my own code.

Notes: I was reading the Jquery .on() but I need to specify an event, however the issue is that I do not know the many "places/events" from the original source code are processing this.

Update: At this point I am "manually" calling my function:

function MyOverrideAction(){
    $.each( $( ".sch-gantt-terminal" ), function( key, value ) {
      // here I have all my logic.... based on several rules (non relevant to my stackoverflow question)
    });
}

I just want that this function is executed every instance when some HTML element is using my target css class.

Dryadwoods
  • 2,875
  • 5
  • 42
  • 72
  • Where is your code ? Show us – Sudharsan S Jul 07 '15 at 08:34
  • " times to times is released a new version", "One way that is "half" working for me is to find all the elements that are using a specific CSS class (or group of classes) and them I am removing it" whats the relavence here? whats the actually issue you are trying to solve and where is your code/jsfiddle? – atmd Jul 07 '15 at 08:36
  • It's not clear what your problem is. I understand you are trying to override a plugin. Can you show which part of a plugin your are trying to override? – Jamie Barker Jul 07 '15 at 08:53
  • @JamieBarker which part of the question "How to catch the use of a CSS class?" is not clear??? It seams that you are the only one to not get it and to vote to close this question.... shame on you really :) – Dryadwoods Jul 07 '15 at 09:46
  • @Dryadwoods The **use** part. The term "_How to catch the use of a CSS class_" is ambiguous. Does it mean CSS, does it mean jQuery, does it mean applying styles, does it mean the running of functions against them? I'm not the only one, look around. atmd didn't know, and JotaBe gave an answer along the same line of thought I was going with, to do with CSS declarations. Also, when people are genuinely trying to help you, for free, expecting nothing in return, it helps to not be complete jackass. – Jamie Barker Jul 07 '15 at 09:57

2 Answers2

1

It is much easier to redefine the CSS class after the original definition. One way to do it is to attach an inline style tag at the bottom of the document which redefines the style. You can use jQuery.append for this. For example see this.

Community
  • 1
  • 1
JotaBe
  • 38,030
  • 8
  • 98
  • 117
0

Maybe you search something like this:

https://stackoverflow.com/a/3219767/5035890

If you listen a change in the DOM you can apply all actions that you need. With MutationObserver you can achieve it. Please, consider of the compatibility.

Good luck

Community
  • 1
  • 1
Marcos Pérez Gude
  • 21,869
  • 4
  • 38
  • 69