Question: I have a view in my asp.net mvc4 web app from which user can configure some things related to it. When user click on a button in this view, let's say, configure view, I want to call a jquery function in another view, let's say, main view. This jquery function is in charge of modifying an element in the main view. 

In the configure view where button is, I have below code, some input textboxes and the button (this calls to action AddItem in Configure controller):

```
   @using (Html.BeginForm("AddItem", "Configure", FormMethod.Post))
   {   
        @Html.DropDownListFor(m => m.CustomViewModel.SelectedItemId, Model.CustomViewModel.ListItems)
        @Html.TextBox(...)
        <input id="submitAdd" type="submit" value="@Resource.ButtonTitleAdd" />
   }

```

So how to do call a jquery function in main view from the above code when user clicks on the button on configure view?

Also I need to pass to this jquery function the value select in the dropdown list of configure view. For example, if dropdown list contains:

"something1"
"something2"
"something3"

I need to pass the value of the item selected in the dropdownlist. For example, if user selects "something1" and its value is 1, 1 should be passed to this jquery function. This dropdown list is populated with a model.

Answer: 
I would have solved it with a custom event, which you can trigger and listen to from where ever you like.

Trigger it like this:

```
$.event.trigger('customStuff', [arg1, arg2, argN]);

```

And "listen" for it like this:

```
$(document).on('customStuff', function (e, arg1, arg2) { });

```
As you are using jQuery. I think something like pubsub is your best bet & it encourages event based loose coupling. For example:

```
(function($) {

  var o = $({});

  $.subscribe = function() {
    o.on.apply(o, arguments);
  };

  $.unsubscribe = function() {
    o.off.apply(o, arguments);
  };

  $.publish = function() {
    o.trigger.apply(o, arguments);
  };

}(jQuery));

```

Now you can use this code as following:

```
// You can pass your custom data here
$.subscribe("firefunction", function(e, a, b, c) {
  console.log(a + b + c);
});

$.publish("firefunction", [ "a", "b", "c" ]);
// logs: abc

// Unsubscribe all handlers for this topic
$.unsubscribe("firefunction"); 

```