However, the scripts generated have dependencies on jQuery among others. Now, good practice is to put your scripts in the bottom of the html document, just before the closing body tag.
I figured I could just move the snippet to a layout page and render the partial there, but I'm having troubles getting t he FormId required to render the partial. What is the recommended approach here?
It's a current workitem in our issue tracker http://issues.umbraco.org/issue/CON-271 to add an easy way of making it possible to add the scripts to the bottom or your page, will see if I can make some progress on it today and report back
Only problem seems to be jQuery 1.9.x, where stuff starts to break. When using jQuery 1.9.1 I get the following error when submitting a form:
Uncaught SyntaxError: Unexpected token u
Which seems to normally be an indication that a value given to JSON.parse is undefined. From what I can gather, jQuery in version 1.9.x and forward correctly throws an error instead of silently swallowing it. So, I'm assuming, that for some reason Contour is trying to parse something that is undefined. Unfortunately that means I'm forced to run jQuery 1.8.3. Guess it will have to do for now.
Client side validation
In the Form.cshtml a partial is used to generate the required scripts for client side validation:
However, the scripts generated have dependencies on jQuery among others. Now, good practice is to put your scripts in the bottom of the html document, just before the closing body tag.
I figured I could just move the snippet to a layout page and render the partial there, but I'm having troubles getting t he FormId required to render the partial. What is the recommended approach here?
Comment author was deleted
It's a current workitem in our issue tracker http://issues.umbraco.org/issue/CON-271 to add an easy way of making it possible to add the scripts to the bottom or your page, will see if I can make some progress on it today and report back
Ok, that would be very nice. In the meantime, are there any workarounds? Like a way to get FormIds for a given page?
Comment author was deleted
Well you'll have to build the form model and then pass it to, haven't tested this but try
var Model = new Umbraco.Forms.Mvc.Models.FormViewModel();
Model.FormId = CurrentPage.formPickerProperty
Model.Build();
Yeah, was thinking about something like that. My only issue is that I'm inserting the form in a RTE field. However, I found a solution :)
Btw, have you considered updating jQuery etc. to newer versions?
Comment author was deleted
Haven't tried but think it's save to update them to a newer version on your frontend
Yeah, thought so too, and it almost is :)
Only problem seems to be jQuery 1.9.x, where stuff starts to break.
When using jQuery 1.9.1 I get the following error when submitting a form:
Which seems to normally be an indication that a value given to JSON.parse is undefined. From what I can gather, jQuery in version 1.9.x and forward correctly throws an error instead of silently swallowing it. So, I'm assuming, that for some reason Contour is trying to parse something that is undefined. Unfortunately that means I'm forced to run jQuery 1.8.3. Guess it will have to do for now.
Comment author was deleted
Ok thanks for the details will add this to our issue tracker http://issues.umbraco.org/issue/CON-323
is working on a reply...