TypeError: dependentPropertyElement[0] is undefined

Nov 16, 2012 at 9:10 AM
I get this error when I submit my page
TypeError: dependentPropertyElement[0] is undefined
dependentValue = dependentPropertyElement[0].value;

mvcfoolproof.unobtrusive.js -line 100

My Current scripts are

http://localhost:3248/Scripts/jquery-1.8.2.js

http://localhost:3248/Scripts/jquery.unobtrusive-ajax.js

http://localhost:3248/Scripts/jquery.validate.js

http://localhost:3248/Scripts/jquery.validate.unobtrusive.js

http://localhost:3248/Scripts/mvcfoolproof.unobtrusive.js

I have read http://foolproof.codeplex.com/discussions/227722, but the build seems to be much earlier so I assume it is not that. 

What am I missing?

Nov 21, 2012 at 8:13 AM

Any help?

Coordinator
Nov 21, 2012 at 1:54 PM
I might be able to help with more information. You might need to throw together a small project with a sample model that duplicates the issue to post.
Nov 21, 2012 at 5:17 PM
Edited Nov 21, 2012 at 5:19 PM

Hi Nick

I have a test application. Where can I send it?

In the mean time here is more info

My View

 

@model TestMvc.Models.TestFoolproofModel

@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    @Scripts.Render("~/bundles/foolproof")
</head>
<body>
    <div>
        <fieldset>
            <legend>Credentials</legend>
            <ol>
                <li>
                    @Html.LabelFor(m => m.TestValueOne)
                    @Html.TextBoxFor(m => m.TestValueOne)
                </li>

            </ol>
        </fieldset>
        <input type="submit" value="Register" />
    </div>
</body>
</html>

My Bundel
 public static void RegisterBundles(BundleCollection bundles)
 {
      bundles.Add(new ScriptBundle("~/bundles/foolproof").Include(

      "~/Scripts/jquery-1.8.2.js",
               
      "~/Scripts/jquery.unobtrusive-ajax.js",
               
      "~/Scripts/jquery.validate.js",
               
      "~/Scripts/jquery.validate.unobtrusive.js",
               
      "~/Scripts/mvcfoolproof.unobtrusive.js"));

}


My Model
 
public class TestFoolproofModel
 {
       [RequiredIfTrue("TestValueTwo")]
       public string TestValueOne { get; set; }
       public bool TestValueTwo { get { return true; } }
 }



Whenever I click on the Register button in my view I get
dependentValue = dependentPropertyElement[0].value;
in  mvcfoolproof.unobtrusive.js -line 100
and then a postback

Coordinator
Nov 21, 2012 at 9:55 PM
Send it to nicholasriggs@gmail.com


On Wed, Nov 21, 2012 at 11:17 AM, pirovorster <notifications@codeplex.com> wrote:

From: pirovorster

Hi Nick

I have a test application. Where can I send it?

In the mean time here is more info

My View

@model TestMvc.Models.TestFoolproofModel

@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    @Scripts.Render("~/bundles/foolproof")
</head>
<body>
    <div>
        <fieldset>
            <legend>Credentials</legend>
            <ol>
                <li>
                    @Html.LabelFor(m => m.TestValueOne)
                    @Html.TextBoxFor(m => m.TestValueOne)
                </li>

            </ol>
        </fieldset>
        <input type="submit" value="Register" />
    </div>
</body>
</html>

My Bundel
 public static void RegisterBundles(BundleCollection bundles)
 {
      bundles.Add(new ScriptBundle("~/bundles/foolproof").Include(

      "~/Scripts/jquery-1.8.2.js",
               
      "~/Scripts/jquery.unobtrusive-ajax.js",
               
      "~/Scripts/jquery.validate.js",
               
      "~/Scripts/jquery.validate.unobtrusive.js",
               
      "~/Scripts/mvcfoolproof.unobtrusive.js"));

}


My Model
 
public class TestFoolproofModel
 {
       [RequiredIfTrue("TestValueTwo")]
       public string TestValueOne { get; set; }
       public bool TestValueTwo { get { return true; } }
 }



Whenever I click on the Register button in my view I get

Read the full discussion online.

To add a post to this discussion, reply to this email (foolproof@discussions.codeplex.com)

To start a new discussion for this project, email foolproof@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Nick Riggs
Coordinator
Nov 22, 2012 at 2:31 PM

In order to validate against the second property client-side, it has to be represented in the HTML. For example:

@Html.HiddenFor(m => m.TestValueTwo)

Also, in this example, the model would be null since you are not passing it to the view from the controller. You would need to change your action result to following so the value of "true" actually gets applied to the rendered hidden input box.

return View(new TestFoolproofModel());
That should work for you. Let me know. 

Nov 22, 2012 at 4:09 PM

Hi Nick
Thanx for the help. Works in my test app. Will test it in my main aplication and let you know as well.

Regards
Piro

On Nov 22, 2012 4:31 PM, "nickriggs" <notifications@codeplex.com> wrote:

From: nickriggs

In order to validate against the second property client-side, it has to be represented in the HTML. For example:

@Html.HiddenFor(m => m.TestValueTwo)

Also, in this example, the model would be null since you are not passing it to the view from the controller. You would need to change your action result to following so the value of "true" actually gets applied to the rendered hidden input box.

return View(new TestFoolproofModel());
That should work for you. Let me know.

Read the full discussion online.

To add a post to this discussion, reply to this email (foolproof@discussions.codeplex.com)

To start a new discussion for this project, email foolproof@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com