Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8170151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:04:38+00:00 2026-06-06T21:04:38+00:00

Working with ASP.NET MVC, KnockoutJS and I am using Require JS. I have a

  • 0

Working with ASP.NET MVC, KnockoutJS and I am using Require JS.

I have a view that I am passing back a object that retains 2 Knockout view models. To keep this simple, the parent view is a list of projects. You have the ability to Create a new product or edit one on the list by clicking the appropriate button. Either button will intialize a jQuery dialog which is populated by getting a returned PartialView from my controller.

At the time the partial view is retrieved, I bind a Knockout View model (property on the original returned RequireJS object) to that partial view. I have no problems creating a new product, taking the KO view model and saving it back to the controller action.

The Problem

The problem comes in when attempting to load an existing product into the PartialView. I need to be able to populate the KO viewModel with initial values. A possible solution would be if I could pass the MVC View model from the controller into my existing RequireJS object I could initialize the KO viewmodel with the existing properties values. However, I can’t figure out how to access the existing returned javascript object on the product list view in my partialview view.

The only wrong way that I can get the MVC model on the partialview passed in, is if I wire up Require JS on the partial view and pass back a new instance of the object and pass in the MVC Model, but that just breaks the current jQuery dialog call backs to the original object.

Example:

Parent Product List View

      ......bunch of html
     </li>
   </ul>
 </div>

 @{
   <script type="text/javascript">
      require(['jquery', 'items/adminItemsList', 'jquery-validate-unobtrusive' ],    function ($, viewModel) {
        $(function () {
             viewModel.initialize({
              addUrl: '@Url.Action("Add")',
              listUrl: '@Url.Action("List")',
              editUrl: '@Url.Action("Edit")',
              deleteUrl: '@Url.Action("Delete")'
          });
      });
  });

}

The jQuery Dialog PartialView

      ....bunch of Html
   </div>
  </div>

 <script type="text/javascript">
    viewModel.Model(@Html.Json(Model))   //I need to be able to do something like this
 </script>

The Json method is just a HtmlHelper extension.

How do I setup the returned RequireJS object to be accessible, or what is a better way to design this.

I have and need:

  1. I have Product List View
  2. A View for a Create/Edit Product
  3. The Product list View javascript owns the jQuery Dialog that generates the Create/Edit product view so it needs to not break the callback functions (i.e. onSuccessfulSubmit…)

Thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:04:39+00:00Added an answer on June 6, 2026 at 9:04 pm

    What I ended up doing is splitting out my ViewModels (since really there is two different views) and on the one ViewModel that I need to pass the rendered MVC Model object, I made it an accessible public property off the ViewModel so it can be accessed and serialized by the shared components of the other ViewModel.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on asp.net MVC 3 application. I have created a Razor view
I'm working with ASP.NET MVC 2. I have a bunch of partial views that
I have an ecommerce working in ASP.Net MVC. I'm using Caching to improve performance
The DataAnnotations validator not working in asp.net mvc 4 razor view, when using the
Working in ASP.NET MVC, I have a view model with an Amount field. The
I am working in ASP.NET MVC 3 application, I am using razor view. I
While working with ASP.NET MVC, I have noticed that exception messages issued by the
I'm working with ASP.NET MVC and jQuery and I have a UserControl that is
I don't have grid view as I am working on asp.net MVC. So can
I am working on ASP.net MVC 3.0 Razor View Engine Application. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.