Solved

Jquery Load Elements Script

Posted on 2013-01-15
2
251 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
[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 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

691 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