Jquery Ajax issue

I am working on a tip popup windows for my project. When the user clicks the 'turn on tips' button, the tips windows will show next to some elements.

My problem is that I have elements created from ajax that need to have tips window shown next to them as well and if the user clicks the button BEFORE ajax call, those element won't have tips windows shown because they didn't exist. Are there any suggestions to this problem? Thank a lot.

Answers


You could use on() to act as a delegate for dynamic elements to bind events. Below, I am registering click events to any event that now or later exists on the document with a class called tips.

$(document).on('click','.tips', function(){
   // show tips;
});

Need Your Help

Button in dialog not behaving as a button when clicked

java android xml alertdialog android-alertdialog

After create and testing my custom dialog I've noticed that my button does not show any visual sign of change (such as the ripple effect or highlighting) when clicked. Does anyone know what I'm doing

jQuery can't bind event to AJAX loaded element using .on()

events jquery binding javascript-events

Using .load, I'm loading the following content into #step_2 div:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.