1

I cant figure how to work this out, maybe you can help me. I have a MVC4 project with a customer model and an event model.

When I access the create view for the event, I would like to select a customer (via dropdownlist, this is ok and working) or if the customer I want is not created yet, create it inside the event create view (not to close this view, open customer view, create customer, go back to event create view...). How can I do that? Any ideas?

Thanks everybody!

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
  • http://stackoverflow.com/questions/7968234/render-partial-view-from-other-controller This might help you. You need to render your view for creating a customer inside that current view. E.g; you could use Ajax to pop up a form. – Christophe De Troyer Jan 09 '14 at 08:46
  • What if the customer is created and i dont need to render that view? – user3168759 Jan 09 '14 at 08:55
  • Well that logic can be implemented in JavaScript for example. By means of a button "Create new customer" which pops up the view? Sergey Yanchenko Just answered what I mean! :) – Christophe De Troyer Jan 09 '14 at 09:07

1 Answers1

2

Can be done through the form and ess or partial view. I understand the question?

HTML

<div id="dialog-form">
        <form>
            ...
        </form>
    </div>

js

function openDialogForm() {
    $("#dialog-form").dialog("open");
}


function closeDialogForm() {
    $("#dialog-form").dialog('close');
}

function dialogForm() {
    if ($('#dialog-form').length) {
        $('#dialog-form').dialog({
            autoOpen: false,
            height: 200,
            width: 475,
            modal: true,
            resizable: false,
            show: "slow",
            open: function () { $('.ui-widget-overlay').bind('click', function () { $("#dialog-form").dialog('close'); }); }
        });
    }

Your implementation may be another.

  • Thats a good idea, i think its what im looking for. Just for finishing, if i create a new customer, can i return the code of that customer from the controller to the event create view via ajax? Thanks everybody again! – user3168759 Jan 09 '14 at 09:16