Monday 15 April 2013

javascript - jquery with WordPress loop -


I am using WordPress loop as you can see, a trigger id and a pop up id is how correct How do jquery empliers work? Now the first post in the loop will work. Any help is greatly appreciated.

Loop

  while (has_posts ()): the_post (); ? & Gt; & Lt; A href = "#" id = "trigger_pop_up_   

jquery

  & lt; Script & gt; JQuery (document) .ready (function ($) {// one click event // binding // using jQuery v.1.7.0 instead of .on () .bind () $ ('# trigger_pop_up_ & lt ;? php The_ID (););? & Gt; ') Prevents default work to trigger (click ', function (e)) // E.preventDefault (); // triggering b popup, when click event is removed $ (' #pop_up_ & lt; Php The_ID () ;? & gt; '). BPopup ();});}); & Lt; / Script & gt;    

The PHP code is not executed inside Javascript files, so & lt; ? Php the_ID (); ? & Gt; Nothing does and will probably cause JS errors that will prevent your code from running.

What you have to do is to parse the id field manually.

  & lt; Script & gt; Use jQuery (document) .ready (function ($) {// one click event binding // jquery v.1.7.0 .bind () instead of $ ("a # [id * = 'trigger_pop_up_'])" ) .bind ('click', function (e) {// prevents default task to trigger E.preventDefault (); var id_number = parseInt (this.attr ('id'). ('Trigger_pop_up_' replaced , ''), 10); // Triggering B popup when click event $ ('# pop_up_' + id_number) is removed .bPopup ();});}); & Lt; / Script & gt;   

Should do this.

No comments:

Post a Comment