I want to do this, because I am working with third-party scripts releated to Internet Marketing. Some of them may contain jQuery library included within and it interfere with recent or latest jQuery Library that is included on my website.
Hence, I'd like to switch between .on() and .bind() dynamically upon website load with a help of variable.
For example, let's say I have global variable:
var incJS = false;
And now depending of the third-party script, I know if they have older Lib included so I'd use this.
function tpNetwork ()
{
incJS = true;
startGateway('XXXXX');
$('#fancybox-outer')
.delay(1000)
.fadeTo(300, 1);
preventGTW();
widgetStyle();
}
Now as you may see there's a function at the very bottom widgetStyle()
That function contain loads of things, but important part is following:
$(window).on('resize', function () {
if ($('.widget_wrap').length) widgetCenter_horizontal();
});
It has .on() method there. That is not supported in very old jQuery that's been used by that third-party network. I'd like to switch every single .on() with .bind() but I don't know how to, without duplicating things. I did it like this, but it's duplicate and I believe there's easier way.
if (!incJS)
{
$(window).on('resize', function () {
if ($('.widget_wrap').length) widgetCenter_horizontal();
});
}
else
{
$(window).bind('resize', function () {
if ($('.widget_wrap').length) widgetCenter_horizontal();
});
}
Any kind of tips/help is appreciated. I am really out of any ideas and by doing researches I found nothing.