diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Scripts/setup.js b/src/Orchard.Web/Modules/Orchard.Setup/Scripts/setup.js
index 5c34f3426..1c5054cde 100644
--- a/src/Orchard.Web/Modules/Orchard.Setup/Scripts/setup.js
+++ b/src/Orchard.Web/Modules/Orchard.Setup/Scripts/setup.js
@@ -16,7 +16,7 @@
(function($) {
$(document).ready(function() {
$("select.recipe").change(function() { // class="recipe" on the select element
- var description = $(this).find(":selected").attr("recipedescription"); // reads the html attribute of the selected option
+ var description = $(this).find(":selected").data("recipe-description"); // reads the html attribute of the selected option
$("#recipedescription").text(description); // make the contents of
be the escaped description string
});
$(".data").find('input[name=DatabaseProvider]:checked').click();
diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.cshtml b/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.cshtml
index 8221c1997..59a1f5bc7 100644
--- a/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.cshtml
+++ b/src/Orchard.Web/Modules/Orchard.Setup/Views/Setup/Index.cshtml
@@ -1,4 +1,5 @@
@model Orchard.Setup.ViewModels.SetupViewModel
+@using Orchard.Recipes.Models;
@{
Script.Require("jQuery");
Script.Require("ShapesBase");
@@ -8,6 +9,18 @@
var groupedRecipes = Model.Recipes.Where(x => !String.IsNullOrWhiteSpace(x.Category)).GroupBy(x => x.Category);
var unspecifiedCategoryRecipes = Model.Recipes.Where(x => String.IsNullOrWhiteSpace(x.Category)).ToList();
}
+@helper RenderRecipeOptions(IEnumerable recipes) {
+ foreach (var recipe in recipes) {
+ var optionAttributes = new RouteValueDictionary {
+ { "data-recipe-description", recipe.Description }
+ };
+ if (Model.Recipe == null && recipe.Name == "Default") {
+ optionAttributes["selected"] = "selected";
+ }
+ @Html.SelectOption(Model.Recipe, recipe.Name, recipe.Name, optionAttributes)
+ }
+ }
+}
@Html.TitleForPage(T("Get Started").ToString())
@using (Html.BeginFormAntiForgeryPost()) {
@@ -83,17 +96,13 @@ if (!Model.DatabaseIsPreconfigured) {
if (groupedRecipes.Count() > 1) {
}
- foreach (var recipe in recipeGroup.OrderBy(x => x.Name)) {
- @Html.SelectOption(Model.Recipe, recipe.Name, recipe.Name, new { recipedescription = recipe.Description })
- }
+ @RenderRecipeOptions(recipeGroup.OrderBy(x => x.Name))
}
@if (unspecifiedCategoryRecipes.Any()) {
if (groupedRecipes.Any()) {
}
- foreach (var recipe in unspecifiedCategoryRecipes.OrderBy(x => x.Name)) {
- @Html.SelectOption(Model.Recipe, recipe.Name, recipe.Name, new { recipedescription = recipe.Description })
- }
+ @RenderRecipeOptions(unspecifiedCategoryRecipes.OrderBy(x => x.Name))
}
diff --git a/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs b/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs
index ac3d1d948..0e5571ff4 100644
--- a/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs
+++ b/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs
@@ -52,6 +52,10 @@ namespace Orchard.Mvc.Html {
}
public static MvcHtmlString SelectOption(this HtmlHelper html, T currentValue, T optionValue, string text, object htmlAttributes) {
+ return SelectOption(html, optionValue, object.Equals(optionValue, currentValue), text, new RouteValueDictionary(htmlAttributes));
+ }
+
+ public static MvcHtmlString SelectOption(this HtmlHelper html, T currentValue, T optionValue, string text, RouteValueDictionary htmlAttributes) {
return SelectOption(html, optionValue, object.Equals(optionValue, currentValue), text, htmlAttributes);
}
@@ -60,6 +64,10 @@ namespace Orchard.Mvc.Html {
}
public static MvcHtmlString SelectOption(this HtmlHelper html, object optionValue, bool selected, string text, object htmlAttributes) {
+ return SelectOption(html, optionValue, selected, text, new RouteValueDictionary(htmlAttributes));
+ }
+
+ public static MvcHtmlString SelectOption(this HtmlHelper html, object optionValue, bool selected, string text, RouteValueDictionary htmlAttributes) {
var builder = new TagBuilder("option");
if (optionValue != null)
@@ -71,7 +79,7 @@ namespace Orchard.Mvc.Html {
builder.SetInnerText(text);
if (htmlAttributes != null) {
- builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));
+ builder.MergeAttributes(htmlAttributes);
}
return MvcHtmlString.Create(builder.ToString(TagRenderMode.Normal));