Link to home
Start Free TrialLog in
Avatar of lateapex
lateapex

asked on

jQuery UI how to get rid of inline function

Experts,

Environment: jQuery UI; Dot Net MVC

I'm using an inline function to access some data via json. How do I call the function from the onclick event instead of having it inline. Multiple links or buttons will need to call this function and send in a value?

I've attached the inline jQuery function. "addressID" is what I'll need to pass in.

Thanks!
Bob


$.post("/Report/Address/" + addressId, "",function(data){$("#addressId").val(data.AddressId);$("#street").val(data.Street);$("#city").val(data.City);$("#state").val(data.State);$("#zip").val(data.Zip);}, "json");

Open in new window

Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

why don't you re factor it out in a method

$.post("/Report/Address/" + addressId, "", inlineFunctionReafactored);

function inlineFunctionReafactored(data)
{
}
ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lateapex
lateapex

ASKER

Thanks!