Tooltip/Popover 'element.on is not a function' fix

I was getting an issue on pageload when using popover, "element.on is not a function". These were occurring from some random instances of the tooltip being called where element was equal to the literal string values of 'tooltip' and 'popover'. The errors no longer occurred after checking that the 'element' was indeed an object and not any other type of variable.

This foreach loop was the only part throwing errors, I'm guessing there's something weird going on in my code that's throwing extra values in to the 'triggers' variable.