Using the Google Chrome developer tools, I can see the '/base/TC/FormPost.aspx' request being posted to the server and can also see the expected HTML response being returned from the 'MiniBasketPopup.cshtml' view. However, the variable 'cartContent' is returning null.
Please could anyone suggest what I may be doing wrong?
I've enabled the razor file in the store and I'm seeing the expected view being returned in the XHR response. The POST request also gets a status code of 200 OK so I know that the request and response are fine. It's just the 'var cartContent =' bit that doesn't seem to be working.
Hmm. Actually sounds like it's running the call async and thereby returns nothing, but that's not supposed to happen. Do you have a link where I can try it? If it's a secret link you can mail it to me here: rg [at] teasolutions.dk
Looking at the source code of the Tea Commerce JavaScript API it looks like th renderTemplateFile indeed is called async. I will have Rune look into fixing this :)
Thanks Anders. I have a pressing need to use this feature in the next few days. Will you be able to supply an updated ecommerce.js script within that timescale or should I start looking for an alternative way update my cart?
I added 'async: false' to line 254 of jquery.form.js but still getting a null. Im not sure if this was the correct location to make the change so I'm happy to wait for Rune to work though the fix.
It should be in this line of code you posted :) var cartContent = TC.renderTemplateFile({ templateFile: 'MiniBasketPopup.cshtml', pageId: '1055', cultureName: 'en-GB', storeId: 1, async: false });
Thanks for the link Phil. What Anders writes works like a charm on your site. It was in Tea Commerce v1 that you didn't have to add the async=false setting yourself.
The reason is that you now have the option of making the call async and then hook into the successfn and handle the response there. Adding the async:false setting will make the method return the server response directly.
I will change the documentation of the method, and add the "new" settings options!
Could you add a bit about having to enable the templates for rendering from javascript in the renderTemplateFile documentation.
I've spend half an hour trying to work out what I'd missed that was causing an exception till I gave this thread a read and Rune's first response pointed me in the right direction :(
renderTemplateFile returning null
Hi,
I'm using the Javascript API for Tea Commerce 2.1.3 on an Umbraco 6.2.1 build.
I am calling the renderTemplateFile method in the following way:
var cartContent = TC.renderTemplateFile({ templateFile: 'MiniBasketPopup.cshtml', pageId: '1055', cultureName: 'en-GB', storeId: 1 });
Using the Google Chrome developer tools, I can see the '/base/TC/FormPost.aspx' request being posted to the server and can also see the expected HTML response being returned from the 'MiniBasketPopup.cshtml' view. However, the variable 'cartContent' is returning null.
Please could anyone suggest what I may be doing wrong?
Kind Regards
Phil
What cartContent variable? You might need to be more specific?
Have you enabled the razor file in the Tea Commerce settings for the store?
/Rune
Hi Rune,
Thanks for the quick response!
I'm declaring a variable cartContent to take the output of the TC.renderTemplateFile method call. It is shown in the first part of this line:
var cartContent = TC.renderTemplateFile({ templateFile: 'MiniBasketPopup.cshtml', pageId: '1055', cultureName: 'en-GB', storeId: 1 });
I've enabled the razor file in the store and I'm seeing the expected view being returned in the XHR response. The POST request also gets a status code of 200 OK so I know that the request and response are fine. It's just the 'var cartContent =' bit that doesn't seem to be working.
Any ideas?
Phil
Hmm. Actually sounds like it's running the call async and thereby returns nothing, but that's not supposed to happen. Do you have a link where I can try it? If it's a secret link you can mail it to me here: rg [at] teasolutions.dk
/Rune
Thanks Rune. I've sent a link to the email address you provided. Hope all makes sense. Please let me know if you need any further information.
Hi Phil and Rune
Looking at the source code of the Tea Commerce JavaScript API it looks like th renderTemplateFile indeed is called async. I will have Rune look into fixing this :)
Kind regards
Anders
Thanks Anders. I have a pressing need to use this feature in the next few days. Will you be able to supply an updated ecommerce.js script within that timescale or should I start looking for an alternative way update my cart?
Try send async: false in the settings object
Kind regards
Anders
I added 'async: false' to line 254 of jquery.form.js but still getting a null. Im not sure if this was the correct location to make the change so I'm happy to wait for Rune to work though the fix.
It should be in this line of code you posted :)
var cartContent = TC.renderTemplateFile({ templateFile: 'MiniBasketPopup.cshtml', pageId: '1055', cultureName: 'en-GB', storeId: 1, async: false });
Kind regards
Anders
Thanks for the link Phil. What Anders writes works like a charm on your site. It was in Tea Commerce v1 that you didn't have to add the async=false setting yourself.
The reason is that you now have the option of making the call async and then hook into the successfn and handle the response there. Adding the async:false setting will make the method return the server response directly.
I will change the documentation of the method, and add the "new" settings options!
/Rune
Thanks guys! I've tested it and it looks great. I'll come back and give you both high fives when I've got enough karma.
Cool. Here's a high five from me to you then :)
Thanks for pointing out this documentation problem!
/Rune
Could you add a bit about having to enable the templates for rendering from javascript in the renderTemplateFile documentation.
I've spend half an hour trying to work out what I'd missed that was causing an exception till I gave this thread a read and Rune's first response pointed me in the right direction :(
Is this "Remember" statement good enough?
http://documentation.teacommerce.net/javascript-api/template-files/rendertemplatefile/
Kind regards
Anders
Perfect xD
Thanks.
is working on a reply...