ethar turky
asked on
jquery 3 and protoype
Dear all,
Once I upgrade to jquery 3.1.1, I got an error when I use prototype:
PropertiesWindow.js:63 Uncaught TypeError: controller.remove is not a function
Once I upgrade to jquery 3.1.1, I got an error when I use prototype:
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
PropertiesWindow.js:63 Uncaught TypeError: controller.remove is not a function
That error does not look like it pertains to the snippet you have posted.
ASKER
Yes its for :
controller = new CategoryController(orignalData);
controller.init(options);
function CategoryController(dataArray) {
if (dataArray) this.dataArray = dataArray;
this.category = {};
this.listObjectMap = {}; // each category with it's List.js object
}
CategoryController.prototype = {
curGroupBy: "groupId",
curSortBy: "asc",
dataArray: [],
categories: {},
init: function (options) {
this.groupBy(this.curGroupBy);
this.render(options);
var self = this;
}
};
ASKER
Error raised :
PropertiesWindow.js:63 Uncaught TypeError: controller.init is not a function
PropertiesWindow.js:63 Uncaught TypeError: controller.init is not a function
This works for me
<script src="http://code.jquery.com/jquery-3.1.1.js"></script>
<script>
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
var x = new Array();
x.push(1);
x.push(2);
x.push(3);
x.push(4);
x.push(5);
x.push(6);
x.push(7);
x.push(8);
console.log(x);
x.remove(3,6);
console.log(x);
</script>
ASKER
what about the code I sent?
I am guessing it is an ordering issue - what happens if you try this
function CategoryController(dataArray) {
if (dataArray) this.dataArray = dataArray;
this.category = {};
this.listObjectMap = {}; // each category with it's List.js object
}
CategoryController.prototype = {
curGroupBy: "groupId",
curSortBy: "asc",
dataArray: [],
categories: {},
init: function (options) {
this.groupBy(this.curGroupBy);
this.render(options);
var self = this;
}
};
controller = new CategoryController(orignalData);
controller.init(options);
It seems to work for me bar the errors about groupBy() not being defined.
ASKER
Thanks for your reply,
groupBy is already defined , I just remove it to make code simple.
In face I call
Also The error raised only when I change jquery from 2.1.1 to 3.1.1.
groupBy is already defined , I just remove it to make code simple.
In face I call
controller = new CategoryController(orignalData);
controller.init(options);
from onclick function.Also The error raised only when I change jquery from 2.1.1 to 3.1.1.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.