yui3 widget error "this.constructor.NAME is undefined" - javascript

I am creating a yui3 widget and I keep getting this error: this.constructor.NAME is undefined.
I am defining a name in my widget:
YUI().add('paginator', function(Y) {
function Paginate(config) {
Paginate.superclass.constructor.apply(this, arguments);
}
Paginate.NAME = "paginate";
...
So, I am not sure what's going on.
Edit:
I also wanted to add that I have just tried to add the default widget skeleton from here and I am still getting the same error.

I thought I would answer this myself in case anyone else comes across this problem. I forgot the new keyword when creating my widget.

Related

TypeError: this._url is undefined at Dojo FilteringSelect onChange callback

I keep getting following error: TypeError: this._url is undefined at the callback of a Dojo FilteringSelect.
I simplified my code to this:
var testFeatures = [
{ "id": 1, "Adresa": "Pyšvejcova 6, Kotěhůlky"},
...
];
var filteringSelect = new FilteringSelect({
id: "testSelect",
autoComplete: false,
searchAttr: "Adresa",
store: new Memory({ data: testFeatures }),
onChange: this.onSelected
}, "testSelect");
filteringSelect.startup();
//end of the function, still in the same define callback
onSelected: function () {
//custom processing
var queryTask = new esri.tasks.QueryTask(this.serviceUrl);
var query = new esri.tasks.Query();
query.outFields = ["OBJECTID"];
query.where = "Adresa=" + dojo.byId("testSelect").value;
query.returnGeometry = true;
queryTask.execute(query, this.zoomToSelected);
}
zoomToSelected: function (featureSet) {
//custom map processing
}
and HTML:
<input id="testSelect" data-dojo-attach-point="testSelect" />
I have no idea where's the problem, Google found no case similar to mine. FireBug says the error occurs in init.js. Console says line 199, but the code in question (...nction(){},onExecuteForCountComplete:function(){},onExecuteForExtentComplete:fun...) is on line 256.
One possible cause of problems might be ArcGIS JavaScript API or Web AppBuilder - this seems not to be one of the "ArcGIS-heavy" parts of the code, but I don't know for sure. It's ArcGIS JS API 3.15 (Dojo 1.10) and Web AppBuilder for developers version 1.4.
EDIT: with help of #KenFranqueiro and this post I made some progress. I can't say that I fully understand the onChange callbacks, but I learnt to omit the parentheses while calling a named function. The onSelected still wasn't called, but modifying the input data to include id solved this. But it didn't solve the main problem...
Now the old good TypeError: this._url is undefined occurs at queryTask.execute, or between it and start of zoomToSelected method. The exact place where the error occurs changed to line 256, column 351, with following referenced code:
...e:function(a,b,c,d,f){var m=f.assembly;a=this._encode(n.mixin({},this._url.query...
There is a pointer at the = after "a", so the error seems to be to the right of it, trying to mixin something non-existent to something else. I have no idea what the this in the init.js should mean. Unfortunately, dojo core code is almost undebuggable without some de-obfuscation. Is this my only option, or does anybody know how to solve it?
So debugging the init.js wasn't so hard, it takes QueryTask as this. As far as I know, this shouldn't have a _url attribute. So I must have some mistake in the queryTask as well.
Obsolete part of the question, archived:
I wonder whether the problem might be caused by the onChange callback's argument, which I don't really understand. I've read several examples of Dojo FilteringSelect with onChange event set, like the official one. Usually it has some argument, but I don't know what does it mean and where it gets from. In the official example it corresponds to the div id and nothing else. However, how is the id translated to a variable and even whether my assumption that it's the id is correct. The detailed documentation is not much helpful in this case.
Older EDIT: testSelect is an object. Seems it was created implicitly with the dom - it's a childnode of this.domNode. So now I understand where it comes from, but not how to prepare another function to be called on change and why the correct syntax is what it is.
Also, I don't know where exactly is the problematic undefined this._url supposed to exist. In my example, this refers to the dijit, but I have no idea what is the scope of the part of init.js where the problem occurs.
I'm not sure how much related are the two subquestions (confusion in the onChange callback and identification of this in init.js), I only suppose they are symptoms of the same issue since the error is thrown at the onChange event in my code.
The problem at the query was caused by this.serviceUrl either missing as a part of wrong coontext, or being an object instead of a URL string. So the final step was to make sure the correct context is used (by lang/hitch) and then setting this.serviceUrl to be what I originally thought, one of the attributes of the object referenced as serviceUrl before.

Uncaught reference error: slider is not defined

I'm trying to implement joss benner's fix as shown here. I need to implement this code:
slider.setOpts = function(opts) {
for (var opt in opts) {
vars[opt] = opts[opt];
}
slider.setup();
}
slider.getOpts = function() {
return vars;
}
I've tried with this fiddle here, but I just get
Uncaught ReferenceError: slider is not defined
in the console. Not really what I'm doing. The other commenters seem to be able to implement it no problem.
Could someone also explain the meaning behind the code... what is slider? A class? A function? Where should I place the above code to add the .setOpts function?
He wrote
I added these public methods to flexslider
To do so, you have to add those lines of code inside the jquery.flexslider.js-file and not in another js-file as you did in the fiddle. The error tells you what the problem is. And in your case, slider is in fact not defined, because the slider-variable is being declared inside a codeblock of the jquery.flexslider.js which means, there is no reference to this variable outside of this block.
The public methods start in line 426, so add your code there.

Updating object within function

Anybody suggest why the button doesn't work here? I must have a syntax error but the console is showing no errors and the JS is valid. http://jsfiddle.net/FZ6K6/20/
self.msg = function () {
self.msgbox = {
status: "information",
message: "Enter some info"
};
You're passing a constructor function to applyBindings().
Since the function itself has no useful properties, nothing happens.
You probably want to pass an instance of that function using new.
There are a couple issues here, including the lack of an instance of your View Model.
Check out the notes I posted on this updated fiddle:
http://jsfiddle.net/FZ6K6/22/
ko.applyBindings(new FormViewModel(),document.getElementById('domElementToBind'));
Not only are we 'new-ing' up an instance of FormViewModel, but we're also specifically assigning a DOM element to apply the bindings to...which is good practice.

Error with jQuery Session

I'm hoping someone can help me as I'm trying to store relatively simple values into a session with jQuery (values from a select field). I've been trying to use this plugin here, but it is throwing an error on the page load. The error is as follows...:
Uncaught TypeError: Object function each(iterator, context) {
try {
this._each(iterator, context);
} catch (e) {
if (e != $break) throw e;
}
return this;
} has no method 'split'
I've read that this could be a conflict with Prototype so I added the following to the top of the jquery.session.js file and changed all instances of '$' to 'jQuery' to no avail.
jQuery.noConflict();
I'm not entirely set on this plugin and would be willing to use a different one if suggested to do so. I'm just hoping it is a quick fix someone is familiar with, or suggestions for another possible solution.
Thanks!
Here's a site that explains the html5 session storage.
http://www.nczonline.net/blog/2009/07/21/introduction-to-sessionstorage/

dojo.declare: unknown base class - dojo.Stateful

So I'm learning Dojo and seeing what I can do with it - I do apologise if this is a stupid question but I can't find a solution.
My code:
dojo.require("dojo.Stateful");
dojo.declare('W.Model',dojo.Stateful,{
foo:'bar'
});
The error:
Uncaught Error: declare W.Model: unknown base class. Did you use dojo.require to pull it in?
I did use dojo.require to pull it in. What am I missing?
Edit - console.log(dojo.Stateful); returns undefined. I am using Google to hot Dojo for me - here: <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js"></script>
Other classes are loading fine, just dojo.Stateful is a problem.
Do you have the full class declaration in a separate file? Or is this all inline on a page?
If you are doing it inline, wrapping the class until the page has loaded will fix the problem:
dojo.require("dojo.Stateful");
dojo.ready(function() {
var x = new dojo.Stateful();
console.log(x);
dojo.declare('some.class', dojo.Stateful, {
'x':'y'
});
});

Categories