سؤال

I would like to use a lightbox plugin (lightbox_me for this case) to lightbox a html DOM element returned by an ajax request.

Here is my code:

<script src="script/jquery.lightbox_me.js"></script>

<script>

 $("#about").click(function(e){
  e.preventDefault();
 $.ajax({
  url : "about.html",
  success : function(html){
  (html).lightbox_me();
 });
});

</script>

However the lightbox doesn't shows up. I have a console message which says:

has no method 'lightbox_me'

هل كانت مفيدة؟

المحلول

Your missed out a $ sign

<script src="script/jquery.lightbox_me.js"></script>

<script>

 $("#about").click(function(e){
  e.preventDefault();
 $.ajax({
  url : "about.html",
  success : function(html){
  //A dollar sign must be before the (html)
  $(html).lightbox_me();
 });
});

</script>

نصائح أخرى

this line should be?

 (html).lightbox_me();

or so:

 $(html).lightbox_me();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top