How to fix 'this.stickit() is not a function' error in Backbone.stickit

185 views Asked by At

I am trying to use backbone.stickit together with Marionette but somehow it doesn't recognize the stickit function. I keep getting the error:

this.stickit() is not a function

I am using versions Backbone 1.3.3, Marionette 2.4.7 and stickit 0.9.2. I have tried older and newer versions of both Backbone and Marionette but it does not solve the issue. I call the this.stickit() function in the onRender, I also tried to use it in onShow but no luck there. I also have an onDestroy function where I use this.unstickit() and that does not give any errors. Does anyone have any ideas what causes this issue?

import { ItemView } from 'backbone.marionette';
import 'backbone.stickit';
import template from './test.html';

const TestView = ItemView.extend({

  template,

  bindings: {
    '#input-name': 'name',
    '#label-name': 'name'
  },

  onRender() {
    this.stickit();
  },

  onDestroy() {
    this.unstickit();
  }

});

export default TestView;

I have tried earlier versions of backbone and marionette but then I get another error about a 'radio' not found or something. I hope someone can help me solve the this.stickit() is not a function error.

Thanks in advance!

1

There are 1 answers

0
S.Smulders On

Turns out that Stickit installs the latest version of backbone. So there were 2 versions of backbone installed (1.3.3 and 1.4.0). This had been solved by adding a resolution to package.json:

"resolutions": {
    "backbone.stickit/backbone":"1.3.3"
  }