prototype.js issues - prototypejs

I am trying to migrate my application from prototype 1.5 to 1.7
However I get errors using getElementsByClassName
My piece of code looks something like this
this.top = Element.getHeight(Element.getElementsByClassName(cell.element,"Day")[0])
However I get javascript error "Element.getElementsByClassName is not a function"
Any idea how to resolve this error ?

Make your Prototype code more Prototype-y.
this.top = cell.element.down('.Day').getHeight();

Related

Converting Html to Pdf with SelectPdf ArgumentNullException

iam new here and hope someone can help me out.
iam trying to convert a html string to a pdf version in net5. We had it running in net core 2.2 without any problems. Now we are trying to migrate everything to net5. Well the only part which is not working anymore is converting html string to pdf document.
We are using following nuget package: Select.HtmlToPdf.NetCore
As soon we try the convert the html string with "ConvertHtmlString" we get following Exception.
System.ArgumentNullException: 'Value cannot be null. Arg_ParamName_Name'
here is a simple snippet to repdoruce the problem:
var htmlString = "<html><head></head><body>Test me out!</body></html>";
var converter = new HtmlToPdf();
converter.Options.PdfPageSize = PdfPageSize.Letter;
converter.Options.AutoFitWidth = HtmlToPdfPageFitMode.AutoFit;
converter.Options.AutoFitHeight = HtmlToPdfPageFitMode.AutoFit;
converter.Options.PdfPageOrientation = PdfPageOrientation.Landscape;
SelectPdf.PdfDocument doc = converter.ConvertHtmlString(htmlString);
doc.Save("C:\\Temp\\test.pdf");
doc.Close();
Thanks.
Regards Maik
Ok thx for the hint in the comment..
before i posted my question i did some standard stuff i always do before researching deeper..
Clean solution, restarted VisualStudio and so on.. nothing worked.
Ive checked my nuget packages and i had the correct one installed.
I removed the package and reinstalled it again and well it works now. Cant exactly say what the problem was but.. it works now.

Vuepress oidc-client preventing build

It looks like Vuepress is made for public docs, but we decided to add client and server security to protect some of the doc pages. But unfortunately although oidc-client (https://github.com/IdentityModel/oidc-client-js/wiki) works during dev, it throws exception when build.
I get ReferenceError: window is not defined and when I try to trick the compiler with const window = window || { location: {} }; I get TypeError: Cannot read property 'getItem' of undefined
Any idea how to make this work?
This was driving me nuts also. I discovered the component I was trying to add was looking at window.location in its code - this was triggering the error.
My understanding is that the build process has not access to Browser things like window etc.
As soon as I removed the window.location bit from my code things built just fine and all is well.

Javascript Visualforce update object not working

I am new in visualforce apex development, and I am trying to update object of salesforce but its throwing error: "Refused to set unsafe header "User-Agent"".
Please help me out.
I am trying the below code:
function updateAccounts(terrId,accId){
var acc=[];
var contact = new sforce.SObject("ObjectTerritory2Association");
contact.objectid = accId;
contact.territory2id = terrId;
acc.push(contact);
sforce.connection.sessionId = "{!$Api.Session_ID}";
if(terrId!="")
sforce.connection.update(acc);
else
sforce.connection.delete(acc);
}
</script>
Thank you.
I remember running into this problem. I don't remember the exact reason it was happening - something about being a Community User vs. a Salesforce user.
I recommend using JavaScript Remoting instead.

Prototype error in Magento

I'm using the HelloResponsive EE theme on a Magento 1.13 EE deployment.
In setting up an extention for the eWAY gateway, I was told there was an error in the Prototype.js file that was interfering with the JSON post.
Uncaught TypeError: Object.keys called on non-object prototype.js:126 addMethods prototype.js:126 create prototype.js:115 (anonymous function) wishlist.js:38
for (var i = 0, length = properties.length; i < length; i++) klass.addMethods(properties[i]);
The custom theme does use JQuery as well, so this may be a conflict issue. But when I try moving the JQuery call before the Prototype call, the JQuery functions stop working.
Can anyone help explain 1. whether or not the error is related to the Prototype / JQuery conflict (I am using a noConflict script) and 2. how best to fix this?
Thanks!
Randy
Take a look at the answer in this thread and see if it can help you. Essentially, I had an outdated template file in my theme that was missing some key variable definitions:
https://magento.stackexchange.com/questions/7682/error-in-prototype-js

how to parse json multi dimenstional array in titanium or xcode

My drupal developer given a url like:http://feed.local/feed/services/rest/viewget/test.json
then am getting the out put as(when am browsing from chrome browser) below:
[{"nid":"133","node_title":"What is life really all about?"},{"nid":"139","node_title":"What went wrong?"}]
I am using sumitk tutorial that is how to develop iphone app using drupal as base system with titanium.
My problem is how can i parse the above in titanium .Can any one help.....
Or else If any one help me how can i use this in xcode........
You can use Titanium.JSON.parse
JSON.parse will help you, it is a function included by Titanium. Make sure you encapsulate it within a try {} catch(excp) {}
For example:
try
{
var data = JSON.parse('[{"nid":"133","node_title":"What is life really all about?"},{"nid":"139","node_title":"What went wrong?"}]');
}
catch (excp)
{
alert('JSON parse error');
}

Resources