?
Solved

jQuery UI how to get rid of inline function

Posted on 2011-02-22
3
Medium Priority
?
498 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:lateapex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 34958392
why don't you re factor it out in a method

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

function inlineFunctionReafactored(data)
{
}
0
 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 2000 total points
ID: 34958403
now this inlineFunctionReafactored method can be called at onclick etc

or even this can be tried

$.post("/Report/Address/" + addressId, "",function(data){inlineFunctionReafactored(data)}, "json");

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

function inlineFunctionReafactored(data)
{
$("#addressId").val(data.AddressId);
$("#street").val(data.Street);
$("#city").val(data.City);
$("#state").val(data.State);
$("#zip").val(data.Zip);
}
0
 

Author Closing Comment

by:lateapex
ID: 34961914
Thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question