Here's the thing.
I have a page in MVC. this page has a helper.
<% Html.RenderPartial("foldingHelpBox", ViewData["foldingHelpBox"]); %>
So the Action:
public ActionResult Index(int? verbID, string schooljaarparam) {
......
ViewData["foldingHelpBox"] = new InfoFlyout() { Title = "How does this work?", Message = "foldinghelpbox.html" };
return View();
}
What is an InfoFlyout?
public partial class InfoFlyout {
public string Title { get; set; }
public string Message { get; set; }
}
What do I want?
I want an Accordeon like effect, a title and a message. the message is defaultly closed, and opens when you click the title. but I want just 1 item, not multiple like the accordeon has.
The jQuery:
$(document).ready(function () {
$(".foldingHelpText").hide();
$(".foldingHelp").click(function () {
var helptext = $(this).siblings(".foldingHelpText");
if (helptext.is(":hidden")) {
alert(helptext.attr("data"));
helptext.load(helptext.attr("data"));
}
$(this).siblings(".foldingHelpText").toggle("blind", { direction: "vertical" }, 1000);
return false;
});
$(".closedialog").click(function () {
$(this).parent().hide("blind", { direction: "vertical" }, 1000);
});
});
The Partial
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MVC2_NASTEST.Models.InfoFlyout>" %>
<div class="foldingHelpBox">
<a class="foldingHelp" href="#">
<%= Model.Title %></a>
<div class="foldingHelpText" data="<%= Model.Message %>">
<span class="closedialog ui-icon ui-icon-closethick" title="Sluiten"> </span>
</div>
So tell me the problem!
Well, The Message can be 2 things. It can be a string which contains the message, or it could be a string with is actually the name of the HTML file which contains the actual html to put inside the message. This html can be fairly long, that's why i do not want to write it all in 1 string.
The problem is that I am using MVC and the HTML file is in my View folder. I can move it somewhere else though.
I'd like to have DRY code.
there are 2 questions:
How would you do it?
I am now trying to use the jQuery load function to read the html into the foldinghelptext div but i cant get the URL right to the html file. So how would you do it? maybe put the HTML in a partial, name it. the whole lot doesn't look so clean to me.
How do i get the URL of this html file
If my way of doing it is fine, how do i get the URL to the html file, to let jQuery load it.