Microsoft JScript runtime error: 'this.Plugins[...]' is null or not an object
coming from this code:
var xVal = xVal || {
Plugins: {},
AttachValidator: function(elementPrefix, rulesConfig, pluginName) {
if (pluginName != null)
this.Plugins[pluginName].AttachValidator(elementPrefix, rulesConfig);
else
for (var key in this.Plugins) {
this.Plugins[key].AttachValidator(elementPrefix, rulesConfig);
return;
}
}
};
Make sure you are referencing xVal.AspNetNative.js AND xVal.jquery.validate.js in your master page.
Related
I'm getting below error while executing this code -
E/launcher - Error: TypeError: Cannot read property '0' of undefined
Need your help to resolve this issue in Protractor version 5.4.3
let objectLocator = function(){
var webElement = null;
//find locator using provided locator type and locator value
this.findLocator = function (locator, value) {
var locatorType = locator[0];
var locatorValue = locator[1];
if (typeof locatorType !== 'undefined') {
if (locatorValue.includes('#REPLACE#')) {
locatorValue = locatorValue.replace('#REPLACE#', value);
}
if (locatorType == 'id') {
if (locatorValue !== 'undefined') {
this.webElement = element(by.id(locatorValue));
}
} else if (locatorType == 'name') {
if (locatorValue !== 'undefined') {
this.webElement = element(by.name(locatorValue));
}
} else if (locatorType == 'xpath') {
if (locatorValue !== 'undefined') {
this.webElement = element(by.xpath(locatorValue));
}
} else if (locatorType == 'css') {
if (locatorValue !== 'undefined') {
this.webElement = element(by.css(locatorValue));
}
}
}
return this.webElement;
};
};
module.exports = new objectLocator();
I have ClearScript that can do either
error = "value is invalid";
or
error = [
{
language: 'en',
message: "value is invalid"
},
{
language: 'fr',
message: "valeur incorrecte"
}
];
How, in C# can I get the values in the array?
And, to get either one case or the other I don't have a choice to do a try/catch, do I?
If your script sets up a global variable named error as shown above, you can process it like this:
dynamic error = engine.Script.error;
var message = error as string;
if (message != null) {
Console.WriteLine(message);
}
else if (error is ScriptObject) {
if (error.constructor.name == "Array") {
for (var i = 0; i < error.length; ++i) {
Console.WriteLine("({0}) {1}", error[i].language, error[i].message);
}
}
else {
// handle other error types
}
}
I´m trying to get the Title and the order of all the content controls in a Word document. The following code works:
function readContentControlsTitle() {
Word.run(function (context) {
var myDocParagraphs = context.document.body.paragraphs;
context.load(myDocParagraphs, 'text, outlineLevel');
return context.sync().then(function () {
for (var i = 0; i < myDocParagraphs.items.length; i++) {
var parContentControl = myDocParagraphs.items[i].parentContentControlOrNullObject;
context.load(parContentControl, 'title');
paragraphContentControls.push(parContentControl);
}
return context.sync().then(function () {
for (var iCount = 0; iCount < paragraphContentControls.length; iCount++) {
if (paragraphContentControls[iCount].title != null) {
// Some stuff with paragraphContentControls[iCount].title
}
}
return context.sync();
})
})
}).catch(function (error) {
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
}
The problem arise when I insert a table of contents in the document. In that case, I always get an exception in the second context.sync. If I remove the table of contents, it works again. The output of the exception is:
Debug info: {"code":"GeneralException","message":"GeneralException","errorLocation":"Paragraph.parentContentControlOrNullObject"}
My Word version: 16.0.7927.1020
Thank you for discovering the issue. Yes it is a bug. It is fixed now and should be released next month. Before the fix, you can put parentContentControlOrNullObject in a try/catch. Thanks.
The jsTree xml_data plugin is not working in ie 11. It Works great in every browser (including ie10), but not in ie11. No error messages, only the "loading" forever.
$("#hierarquia").jstree({
"xml_data" : {"ajax" : {"url" : "XML.asp"}},
"plugins" : ["xml_data"]
});
Anyone have experienced this? I could not find any references for jsTree and ie11 on the web until now.
Thanks for any help!
In the the jstree.js file there is this function:
(function ($) {
$.vakata.xslt = function (xml, xsl, callback) {
var rs = "", xm, xs, processor, support;
// TODO: IE9 no XSLTProcessor, no document.recalc
if (window.ActiveXObject) {
var xslt = new ActiveXObject("Msxml2.XSLTemplate");
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
xmlDoc.loadXML(xml);
xslDoc.loadXML(xsl);
xslt.stylesheet = xslDoc;
var xslProc = xslt.createProcessor();
xslProc.input = xmlDoc;
xslProc.transform();
callback.call(null, xslProc.output);
return true;
}
if(typeof window.DOMParser !== "undefined" && typeof window.XMLHttpRequest !== "undefined" && typeof window.XSLTProcessor === "undefined") {
xml = new DOMParser().parseFromString(xml, "text/xml");
xsl = new DOMParser().parseFromString(xsl, "text/xml");
// alert(xml.transformNode());
// callback.call(null, new XMLSerializer().serializeToString(rs));
}
if(typeof window.DOMParser !== "undefined" && typeof window.XMLHttpRequest !== "undefined" && typeof window.XSLTProcessor !== "undefined") {
processor = new XSLTProcessor();
support = $.isFunction(processor.transformDocument) ? (typeof window.XMLSerializer !== "undefined") : true;
if(!support) { return false; }
xml = new DOMParser().parseFromString(xml, "text/xml");
xsl = new DOMParser().parseFromString(xsl, "text/xml");
if($.isFunction(processor.transformDocument)) {
rs = document.implementation.createDocument("", "", null);
processor.transformDocument(xml, xsl, rs, null);
callback.call(null, new XMLSerializer().serializeToString(rs));
return true;
}
else {
processor.importStylesheet(xsl);
rs = processor.transformToFragment(xml, document);
callback.call(null, $("<div />").append(rs).html());
return true;
}
}
return false;
};
The if
if (window.ActiveXObject)
You need to add the following to it:
if (window.ActiveXObject || "ActiveXObject")
Hope that makes sense
EDIT:
Changed the if statement to the below, as earlier fix was causing problems on Chrome:
if (window.ActiveXObject !== undefined || "ActiveXObject" in window)
I have the following JavaScript code works in IE6, IE7 and IE8. However, the parentElement() and commonParentElement() are not defined in IE9. Would anyone know how to workaround it?
if (document.selection)
{
var sel = document.selection;
var rng = sel.createRange();
if (rng)
{
if ("Control" == sel.type && typeof rng.commonParentElement != "undefined")
{
targetElement = rng.commonParentElement(); // undefined in IE9
}
else if (typeof rng.parentElement != "undefined")
{
targetElement = rng.parentElement(); // undefined in IE9
}
}
}