Solved

Jquery Load Elements Script

Posted on 2013-01-15
2
244 Views
Last Modified: 2013-01-15
Hi Experts,

I am loading some script like so:
 $('#CompanySuggestions').load('/lists/scripts/php/load.companies.php?Company='+company+'');  

This produces:
<a class="Suggestion">Country1</a>
<a class="Suggestion">Country2</a>
<a class="Suggestion">Country3</a>

I am having problems setting a jquery click function for .Suggestion...

I imagine its because I am loading it in...

Is there a way around this?

Many Thanks
0
Comment
Question by:maccaj51
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 38778831
Use the callback function
 $('#CompanySuggestions').load('/lists/scripts/php/load.companies.php?Company='+company, function(data) {
       $(".Suggestion").click(function() {
             alert("your clicked on suggestion for country: " + $(this).text());
       });
});  

Open in new window

0
 

Author Closing Comment

by:maccaj51
ID: 38778844
Legend
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

920 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

15 Experts available now in Live!

Get 1:1 Help Now