Solved

Jquery Load Elements Script

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JQuery conflicts/syntax issue 4 25
Use Mid in Html 6 23
Session on Html 8 42
Make a span connected to the price so when qty changes so does pricing 11 31
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 …
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
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…

730 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