Closed speshulk926 closed 9 years ago
Well, I figured out why this happened. The link on documentation for the scripts (https://www.twitterbootstrapmvc.com/Documentation) links to (https://www.twitterbootstrapmvc.com/Scripts/TwitterBootstrapMvcJs-3.0.4.js). At the very top it shows: $('.bmvc-3-validation-summary').addClass('alert alert-danger').find('.close').show();
When I look at the Nuget package version, it shows: $('.bmvc-3-validation-summary').has('li').addClass('alert alert-danger').find('.close').show();
I figured the NugetPackage one was maybe more-updated, so I linked that one instead and it kills all my Javascript on the page. I can't see any discernible reason why.
However, when I copy/paste that one line into my existing "working" js file, everything works as intended.
Sorry could not reply earlier and glad you figured this out. Yeah, it's always safer to have latest from nuget.
Though the fact that this script kills all your JavaScript is disturbing. Is there any JavaScript errors in the browser console?
No, but I'll post my bundle config and some more later to see if I may be doing something incorrect.
Thank you for your response.
I tried a few things and it doesn't appear javascript is dead on the page, but my javascript validation is.
I added this and I get the alert:
< button onclick="alert('hey there'); return false;" >Test< /button >
Here's my bundle config.
public class BundleConfig
{
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Content/js/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Content/js/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Content/js/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Content/js/bootstrap.js",
"~/Content/js/respond.js",
"~/Content/js/TwitterBootstrapMvcJs.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/css/bootstrap.css",
"~/Content/css/site.css"));
// Set EnableOptimizations to false for debugging. For more information,
// visit http://go.microsoft.com/fwlink/?LinkId=301862
BundleTable.EnableOptimizations = false;
}
}
Here's my directory structure to show where it is located. The highlighted one is the Nuget package. The one with a version is from the site.
Here's the HTML output showing what order it loaded everything in:
Here's the HTML output of one of the form groups:
Just messing around I moved the reference to TwitterBootstrapMvcJs.js to the jqueryval bundle and it started working. I'm not seeing any other issues after that. I'm guessing it's just an ordering and it wanted to be after the jquery.validate.unobtrusive.js.
Something that might be relevant from the screenshot you showed: you had TwitterBootstrapMvcJs.js
in the ~/bundles/bootstrap
bundle. However, on the page you referenced both, the ~/bundles/bootstrap
and TwitterBootstrapMvcJs.js
file, which means this file was referenced twice in the code. Just wanted to point this out.
I seem to be having an issue when I set ExcludePropertyErrors, it still shows the ValidationSummary border, but nothing inside. So it's "working", but still displaying and I'm not sure why. Since I could not find anyone else having this issue, I'm assuming it's something I'm doing. Here's some relevant code to see what I may be doing wrong.
Before submit:
![image](https://cloud.githubusercontent.com/assets/611769/6358035/dabab130-bc36-11e4-9169-7c1e5be01e09.png)
After submit:
![image](https://cloud.githubusercontent.com/assets/611769/6358053/f19a63d2-bc36-11e4-81fe-e0f4e7f1ab2a.png)