Amit Sharma
Amit Sharma

Reputation: 1088

$scw(...).eventTracking is not a function in the WFFM in Sitecore MVC

i'm facing an issue with web form for marketers with sitecore MVC i'm able to render WFFM on MVC View when i'm rendering this i'm getting error on Console:

   http://screencast.com/t/GMsjXnCbph

& when i'm submitting this genarate en error like:

  http://screencast.com/t/sbDl7LCe

can anyone help me to figure out this issue, this same form is working fine with web layout issue is only with MVC layout

Upvotes: 0

Views: 1047

Answers (2)

Marvin Lacuna
Marvin Lacuna

Reputation: 1812

.. and for Sitecore version 8.0-X

CSS reference:

<link href="~/sitecore modules/Shell/Web Forms for Marketers/Themes/mvc/Fields/Default.css" rel="stylesheet">
<link href="~/sitecore modules/Shell/Web Forms for Marketers/Themes/mvc/Fields/Colors/Default.css" rel="stylesheet">
<link href="~/sitecore modules/Shell/Web Forms for Marketers/Themes/mvc/Fields/Custom.css" rel="stylesheet">
<link href="~/sitecore modules/Shell/Web Forms for Marketers/Themes/mvc/base/jquery.ui.all.css" rel="stylesheet">

JS reference:

<script src="~/sitecore modules/Web/Web Forms for Marketers/scripts/mvc/jquery-1.8.2.min.js"></script>
<script src="~/sitecore modules/Web/Web Forms for Marketers/scripts/mvc/jquery-ui-1.8.24.js"></script>
<script src="~/sitecore modules/Web/Web Forms for Marketers/scripts/mvc/jquery.validate.js"></script>
<script src="~/sitecore modules/Web/Web Forms for Marketers/scripts/mvc/jquery.validate.unobtrusive.js"></script>
<script src="~/sitecore modules/Web/Web Forms for Marketers/scripts/mvc/Fields/sc.fields-unobtrusive.js"></script>
<script src="~/sitecore modules/Web/Web Forms for Marketers/scripts/mvc/Fields/sc.fields-events-tracking.js"></script>
<script src="~/sitecore modules/Web/Web Forms for Marketers/scripts/mvc/Fields/sc.fields-date.js"></script>
<script src="~/sitecore modules/Web/Web Forms for Marketers/scripts/mvc/Fields/sc.fields-captcha.js"></script>
<script src="~/sitecore modules/Web/Web Forms for Marketers/scripts/mvc/Fields/sc.ajax-form.js"></script>

Upvotes: 1

Tom Hawkin
Tom Hawkin

Reputation: 471

You seem to have two different issues going on here. I am not sure why you are getting a null ref, make sure you are using an MVC form on an MVC page and that you have no controllers in your custom code named form. The default forms route in the 'Sitecore.MVC.Config' file also needs to be empty.

As for the JavaScript error, it is because at no point does the event tracking script get added to the page. it seems like a bug and i have reported it to Sitecore.

For now though you can add the script manually to the WFFM razor view.

I added it to ~/views/form/index.cshtml

<script src="~/sitecore/shell/Applications/Modules/Web Forms for Marketers/mvc/Fields/sc.fields-events-tracking.js"></script>

Edit: I have now found that in the WFFM reference guide it actually says that you need to manually add all the css and js files to your main layout file. it is buried in section 3.15.2.

You need to add these js file references:

<script src="~/sitecore/shell/Applications/Modules/Web Forms for Marketers/mvc/jquery-1.8.2.min.js"></script>
<script src="~/sitecore/shell/Applications/Modules/Web Forms for Marketers/mvc/jquery-ui-1.8.24.js"></script>
<script src="~/sitecore/shell/Applications/Modules/Web Forms for Marketers/mvc/jquery.validate.js"></script>
<script src="~/sitecore/shell/Applications/Modules/Web Forms for Marketers/mvc/jquery.validate.unobtrusive.js"></script>
<script src="~/sitecore/shell/Applications/Modules/Web Forms for Marketers/mvc/Fields/sc.fields-unobtrusive.js"></script>
<script src="~/sitecore/shell/Applications/Modules/Web Forms for Marketers/mvc/Fields/sc.fields-events-tracking.js"></script>
<script src="~/sitecore/shell/Applications/Modules/Web Forms for Marketers/mvc/Fields/sc.fields-date.js"></script>
<script src="~/sitecore/shell/Applications/Modules/Web Forms for Marketers/mvc/Fields/sc.fields-captcha.js"></script>
<script src="~/sitecore/shell/Applications/Modules/Web Forms for Marketers/mvc/Fields/sc.ajax-form.js"></script>

and these css references:

<link href="~/sitecore/shell/Themes/Standard/Default/WFM/mvc/Fields/Default.css" rel="stylesheet">
<link href="~/sitecore/shell/Themes/Standard/Default/WFM/mvc/Fields/Colors/Default.css" rel="stylesheet">
<link href="~/sitecore/shell/Themes/Standard/Default/WFM/mvc/Fields/Custom.css" rel="stylesheet">
<link href="~/sitecore/shell/Themes/Standard/Default/WFM/mvc/base/jquery.ui.all.css" rel="stylesheet">

Upvotes: 5

Related Questions