views:

44

answers:

1

I just updated my code to jqueryui 1.8 and it gave me this error: this._mouseInit is not a function. How would I go about fixing this? I have a widget that does mouse start drag and stop. here is my code:

$.widget("ui.boxTool", $.extend({}, $.ui.mouse, {

            _create: function() {
                this.element.addClass("ui-boxTool");
                this.dragged = false;

                this._mouseInit();
                this.width = $('#toPinpoint').width();
                this.height = $('#toPinpoint').height();

                this.helper = $(document.createElement('div'))
                  .css({border:'1px dashed #c2c0c0'})
                  .css({cursor:'crosshair'})
                  .addClass("ui-boxTool-helper");
              },

              destroy: function() {
                this.element
                  .removeClass("ui-boxTool ui-boxTool-disabled")
                  .removeData("boxTool")
                  .unbind(".selectable");
                this._mouseDestroy();

                return this;
              },

          _mouseStart: function(event) {
            var self = this;

            this.opos = [event.pageX, event.pageY];

            if (this.options.disabled)
              return;

            var options = this.options;

            this._trigger("start", event);

            $(options.appendTo).append(this.helper);

            this.helper.css({
              "z-index": 100,
              "position": "absolute",
              "left": event.clientX,
              "top": event.clientY,
              "width": 0,
              "height": 0
            });
          },

          _mouseDrag: function(event) {
            var self = this;
            this.dragged = true;

        ...

            return false;
          },

          _mouseStop: function(event) {
            var self = this;

            this.dragged = false;

            var options = this.options;

            var clone = this.helper.clone()
              .removeClass('ui-boxTool-helper').appendTo(options.appendTo);



            this._trigger("stop", event, { box: clone });

            this.helper.remove();
            //$('.view-mode').remove(this.helper);
            return false;
          }

        }));
+1  A: 

The syntax changed a bit, your opening line:

$.widget("ui.boxTool", $.extend({}, $.ui.mouse, {

Should now be:

​ $.widget("ui.boxTool", $.ui.mouse, {

Make sure to change last line to match as well, })); should be just }); now.

Nick Craver