Site Event calling page function.

Hi

A WIX & Javascript newbie here calling put for guru assistance…

With reference to the below screenshot…I have a read-only dropdown box that I want to be present in all my website pages. To avoid having to duplicate code on every page, and for layout consistency, I placed it in the Header section so that it is present on every page and at the same position.

The dropdown is populated from a collection via some simple JavaScript triggered by its On_Viewport_Enter event. As a Header object, this code resides in the Site Javascript file. It works fine, each page automatically inherits a populated dropdown list within its header that contains the same range of data values. So far, so good.

I now need to implement bespoke search capability for each page. This would be triggered through the dropdown OnChange event in the header. I thus want to implement page-specific JavaScript that can be triggered from an OnChange event in the Header. And here begins my challenge!

I can’t work out - or indeed if its possible - how to call a function within a page from an event triggered in the header. Now, it’s been a long, long time since I did any object-orientated development - early 90’s using PowerBuilder, great days :slight_smile: - but I do vaguely remember the concept of polymorphism in which different objects implement differing functionality under the same function name. And this is what I think i need, or at least a modern day Javascript version of such.

Header.Dropdown.OnChange   > trigger  some_function(parm) 

Page1 implements some_function  to do its own Page1-speficic stuff using parm 
Page2 implements some_function to do its own Page2-speficic stuff using parm 

etc. 

Can any guru’s give me a steer as to how I might approach this ? Can a site-level script even call page-level script ? Could it be implemented through some form of custom events ?

Throw me a lead and I’m generally OK at researching further and working things out , so I;d very much appreciate any assistance at all.

Cheers
Gareth.