Solved

Jquery Load Elements Script

Posted on 2013-01-15
2
242 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
Comment Utility
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
Comment Utility
Legend
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
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)

771 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

10 Experts available now in Live!

Get 1:1 Help Now