Nothing I do is working. I even tried hiding the DIV with the form and showing a thank you DIV. Even that is NOT working! By the way, even the initial document.Ready() is not working. My divSuccess is showing at start up. If the document.Ready() was working,
shouldn't it be hidden?
Yes, all my references to jQuery and fancybox are in my _Layout.cshtml file.
To make sure, I added them to my partial view as well. When I did, I wasn't able to open my modal dialog which I interpreted as a javascript conflict. When I removed it the references from the partial view, everything worked again -- except for the OnSuccess
stuff.
Ok, can you try and move the success div outside the form? and not have the form inside the div as you had earlier? I think that can cause some problem
* REMEMBER TO MARK THE ANSWER TO YOUR QUESTION * .NET Developer (ASP.NET, MVC, WPF) MCTS .NET 4 (Web, WCF)
Blog | Twitter
If I comment out fancybox, then my partial view won't open in a modal dialog.
How do I open a modal dialog using jQuery-UI? I already have all the references to it so just by calling it I should be able to open it -- just don't know how.
Knecke
Contributor
3712 Points
838 Posts
Re: Need help: None of my OnSuccess functions are working
May 30, 2011 05:06 PM|LINK
try wrapping the onsuccess in a jquery document.ready function
$(document).ready(function(){
// your onsuccess method goes here...
});
.NET Developer (ASP.NET, MVC, WPF) MCTS .NET 4 (Web, WCF)
Blog | Twitter
SamU
Contributor
2895 Points
1625 Posts
Re: Need help: None of my OnSuccess functions are working
May 30, 2011 05:13 PM|LINK
Did absolutely nothing!
Here's what it looks like -- just in case I'm not doing it right. My JavaScript/jQuery skills are rudimentary at best.
<script type="text/javascript"> $(document).ready(function () { function displaySuccess() { var successMessage = '<div style="text-align: center;">Thank you...</div>'; $('#divTwitterForm').Html(successMessage); //$('#divTwitterForm').load(successMessageUrl); } }); function closeFancy() { $.fn.fancybox.close(); } </script>Sam
SamU
Contributor
2895 Points
1625 Posts
Re: Need help: None of my OnSuccess functions are working
May 30, 2011 05:28 PM|LINK
Nothing I do is working. I even tried hiding the DIV with the form and showing a thank you DIV. Even that is NOT working! By the way, even the initial document.Ready() is not working. My divSuccess is showing at start up. If the document.Ready() was working, shouldn't it be hidden?
@model MyModels.Companies.CompanyTwitterInfo <h6>Twitter Handle</h6> @using (Ajax.BeginForm("EditTwitterInfoForSpecifiedCompany", "Companies", new AjaxOptions { HttpMethod = "GET", InsertionMode = InsertionMode.Replace, UpdateTargetId = "divTwitter", OnSuccess = "showMeSuccess" })) { <div id="divTwitterForm"> @Html.TextBoxFor(model => model.TwitterHandle) <input type="submit" value="Submit" class="button" /> @Html.HiddenFor(model => model.CompanyId) </div> <div id="divSuccess"> Thank you very much... </div> } <script type="text/javascript"> $(document).ready(function () { $('#divSuccess').Hide(); }); function showMeSuccess() { $('#divTwitterForm').Hide(); $('#divSuccess').Show(); } </script>Sam
Knecke
Contributor
3712 Points
838 Posts
Re: Need help: None of my OnSuccess functions are working
May 30, 2011 05:34 PM|LINK
.NET Developer (ASP.NET, MVC, WPF) MCTS .NET 4 (Web, WCF)
Blog | Twitter
SamU
Contributor
2895 Points
1625 Posts
Re: Need help: None of my OnSuccess functions are working
May 30, 2011 05:37 PM|LINK
Yes, all my references to jQuery and fancybox are in my _Layout.cshtml file.
To make sure, I added them to my partial view as well. When I did, I wasn't able to open my modal dialog which I interpreted as a javascript conflict. When I removed it the references from the partial view, everything worked again -- except for the OnSuccess stuff.
Sam
Knecke
Contributor
3712 Points
838 Posts
Re: Need help: None of my OnSuccess functions are working
May 30, 2011 05:40 PM|LINK
Ok, can you try and move the success div outside the form? and not have the form inside the div as you had earlier? I think that can cause some problem
.NET Developer (ASP.NET, MVC, WPF) MCTS .NET 4 (Web, WCF)
Blog | Twitter
SamU
Contributor
2895 Points
1625 Posts
Re: Need help: None of my OnSuccess functions are working
May 30, 2011 05:44 PM|LINK
I did. Same results.
Do you think this is due to FancyBox? I really like FancyBox but do you think it's a better idea for me to use the jQuery-UI dialog?
Sam
Knecke
Contributor
3712 Points
838 Posts
Re: Need help: None of my OnSuccess functions are working
May 30, 2011 05:46 PM|LINK
Can you comment out all the fancybox stuff and see if that solves the problem? And yes, i think you should but still, it shouln't cause this problem
.NET Developer (ASP.NET, MVC, WPF) MCTS .NET 4 (Web, WCF)
Blog | Twitter
SamU
Contributor
2895 Points
1625 Posts
Re: Need help: None of my OnSuccess functions are working
May 30, 2011 05:49 PM|LINK
If I comment out fancybox, then my partial view won't open in a modal dialog.
How do I open a modal dialog using jQuery-UI? I already have all the references to it so just by calling it I should be able to open it -- just don't know how.
Sam
Knecke
Contributor
3712 Points
838 Posts
Re: Need help: None of my OnSuccess functions are working
May 30, 2011 05:50 PM|LINK
Get the fancybox back and change the call to Hide() to hide() with lower characters and see what happens :)
.NET Developer (ASP.NET, MVC, WPF) MCTS .NET 4 (Web, WCF)
Blog | Twitter