1.800.323.3639 | Support | Training

Avtex

jQuery in edit mode in SharePoint 2013

| No Comments

On a project I’m currently working on, we’re using the Bootstrap 3 Sharepoint implementation. The implementation went pretty smoothly out of the box, but we’ve added some custom jQuery to ease the process.

Everything worked fine, except none of our jQuery was applying when a page was in Edit Mode. We were getting the dreaded “TypeError” message, which usually means we’re trying to use jQuery before the jQuery library has loaded. But as best we could tell, the library was loading, and in the proper order.

Finally we tracked down the problem, thanks to a post from Eric Franz.

It turns out that a script used in Edit Mode — assetpicker.js — chooses to use the “$” namespace for itself, thus breaking jQuery’s use of that namespace.

The fix is to use “jQuery” instead of “$” — which is simple (though annoying) if the only jQuery on your site is your own custom code. But if you’re using lots of third-party scripts, it’s not really feasible to convert all instances of “$” to “jQuery”. Your only option in that case is to accept that the scripts just won’t work in Edit Mode.

That’s not a very satisfying option. so here’s hoping Microsoft addresses this issue fairly soon.

Let’s Talk About CX

X