Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Jquery Load Elements Script

Posted on 2013-01-15
2
Medium Priority
?
260 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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and 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 …
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…
Suggested Courses

610 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