Click here to Skip to main content
15,898,035 members
Articles / Web Development / HTML

Implementing RequireJs on BackboneJs

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
3 May 2012CPOL2 min read 24.7K   680   11  
Updating the MVC music store app with RequireJS on BackboneJs
@model RazorApp.Models.Album

@{
    ViewBag.Title = "Create";
}



<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $('#AlbumArtUrl').width(340);
        $('#valSum').hide();

        $('#myForm').bind('invalid-form.validate', function (error, element) {
            $('#valSum').show("slow");
            return false;
        });
    });
</script>
@if (!ViewData.ModelState.IsValid) {
<script type="text/javascript">
    $(function () {   
        $('#valSum').show("slow");
});
</script>
}
<div class = "styler">
@using (Html.BeginForm ("Create", "StoreManager", FormMethod.Post, new { id = "myForm" }))
{       
    <fieldset  class="ui-widget">
        <legend class="ui-state-legend-default ui-corner-top ui-corner-bottom">Create New Album</legend>
        <div id = "valSum" class="ui-state-error ui-corner-all" style="padding: 0 .7em;width:500px"> 
		<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
		<strong>Please correct these Errors</strong> @Html.ValidationSummary(false, "")</p>
	</div>
        <table id="">
                <tr>
                    <td>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.GenreId, "Genre")
                        </div>
                        <div class="editor-field">
                            @Html.CoolDropDownListFor(model => model.GenreId, (SelectList)ViewBag.GenreId, true) <br />
                        </div>
                    </td>
                    <td>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.ArtistId, "Artist")
                        </div>
                        <div class="editor-field">
                            @Html.CoolDropDownListFor(model => model.ArtistId, (SelectList)ViewBag.ArtistId, true) <br />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.Title)
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.Title)
                        </div>
                    </td>
                    <td>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.Price)
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.Price)                           
                        </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <div class="editor-label">
                            @Html.LabelFor(model => model.AlbumArtUrl)
                        </div>
                        <div class="editor-field">
                            @Html.EditorFor(model => model.AlbumArtUrl)                           
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                         <br /> <input type="submit" value="Create" />
                    </td>
                </tr>
            </table>

    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
</div>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions