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
Solved

jQuery UI how to get rid of inline function

Posted on 2011-02-22
3
493 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
  • 2
3 Comments
 
LVL 40

Expert Comment

by:gurvinder372
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:
gurvinder372 earned 500 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 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