Solved

jQuery UI how to get rid of inline function

Posted on 2011-02-22
3
488 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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.…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now