Switch button and method not defined

Hi,

specifically stopPropagationAndPreventDefault() (not allowed this in the title?)

Using the latest version of business pack 4.2.0 and when clicking a switch button the js has an exception calling stopPropagationAndPreventDefault() which doesnt exist.

The file in question is:
bp–SwitchButton

specific code block

var d = k(l(), 1)
  , o = class extends d.ButtonBase {
    initialize() {
        super.initialize(),
        this.$element.click(t=>this.onElementClick(t)),
        this.subscribe(this.binding.checked, this.onCheckedChange)
    }
    onElementClick(t) {
        let {checked: e} = this.binding;
        this.isEnabled && (t.stopPropagationAndPreventDefault(),
        ko.isWriteableObservable(e) && e(!e()),
        this.postback(this.binding.click))
    }
    onCheckedChange(t) {
        this.$element.toggleClass(d.BusinessPackCss.stateChecked, t)
    }
}

using asp (not core)

How to fix this, I have reinstalled and reverted to earlier version (4.13) but still the same

Current workaround is to include below in dotmaster

<dot:InlineScript>
    $.Event.prototype.stopPropagationAndPreventDefault || ($.Event.prototype.stopPropagationAndPreventDefault = function () {
        this.stopPropagation(),
            this.preventDefault()
    });

</dot:InlineScript>

Hi! I don’t think you are doing anything wrong, but when I tried to reproduce the issue, but it always works. The snippet which you placed in the InlineScript should be in dotvvm.businesspack.base script, which should be always loaded. Could you please verify that it indeed loads on your page? Maybe loading jQuery multiple times could cause the issue, can you also check that it loads only once?

thanks for the reply, the dotvvm.businesspack.base script is loading, I can breakpoint it in load, I’ll check for duplicate jQuery loads (this may be happening) across embedded controls

thanks

Jquery is being added twice, i have the latest version as a dependency and Dotvvm business pack is loading v3.2.1, is there a way to configure business pack to not load jquery if it already exists on the page?

You can replace the "jquery" resource used by BP, I suppose it will be compatible with a newer version. If you have in a local file:

config.Resources.RegisterScriptFile("jquery", "./youfile.js")

Thank you,

my jQuery is in a grunt generated bundle and I have removed it from there and linked using your advice to that version of jQuery, All code works as it should.

Thanks again