Click here to Skip to main content
15,895,656 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.ViewModels.SearchAlbumViewModel
@{
    Layout = "";
    
}
<script type="text/javascript">
    $(document).ready(function () {
        $("#storeManagerResults").jqGrid({
            url: '@Url.Action("DoAlbumSearch", Model)',
            datatype: 'json',
            mtype: 'POST',
            emptyrecords: "No results",
            colNames: ['Genre', 'Artist', 'Title', 'Price'],
            colModel: [
            { name: "Genre", width: 100, editable: false, searchoptions: {}, index: "Genre" },
            { name: "Artist", width: 300, editable: false, searchoptions: {}, index: "Artist" },
            { name: "Title", width: 350, editable: false, searchoptions: {}, index: "Title" },
            { name: "Price", width: 75, editable: false, searchoptions: {}, index: "Price" }
            ],
            pager: $('#storeManagerPager'),
            rowList: [10, 20, 30],        // disable page size dropdown
            pgbuttons: true,     // disable page control like next, back button
            viewrecords: true,    // disable current view record text like 'View 1-10 of 100' 
            sortname: 'Genre',
            sortorder: 'asc',
            loadonce: false,
            sortable: true,
            scrollrows: true,
            height: 500,
            hoverrows: false
        });
        $("#storeManagerResults").jqGrid('navGrid', '#storeManagerPager', { 
            edit: true, editfunc: function () { 
                var id = $("#storeManagerResults").jqGrid('getGridParam','selrow');
                $('#albumEdit').load ("@Url.Action("EditAlbum")" + "/" + id);
                $("#albumEditDialog").dialog("open"); return false; },
            add: true, addfunc: function () { 
                $('#albumEdit').load ("@Url.Action("CreateAlbum")");
                $("#albumEditDialog").dialog("open"); return false; },
            del: true, delfunc: function () {
                var id = $("#storeManagerResults").jqGrid('getGridParam','selrow');
                $('#albumEdit').load ("@Url.Action("DeleteAlbum")" + "/" + id);
                $("#albumEditDialog").dialog("open"); return false; },
            search: false
        });
    });
</script>
<table id="storeManagerResults">
</table>
<div id="storeManagerPager">
</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