Skip Navigation

[Gelöst] Pass a dynamic ID in the Views javascript field

This support ticket is created vor 7 Jahre, 9 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 Antworten, has 3 Stimmen.

Last updated by Kris Haamer vor 7 Jahre, 9 Monate.

Assigned support staff: Luo Yang.

Captura de tela 2015-04-10 20.36.07.png

I'm using a view to generate a bunch of cards.

Each card has a unique ID which I need to target with javascript,
however I can't see a way to pass a variable in the view's javascript field.

The js would look something like this. Note the ID "3594" which
I would need to insert dynamically for each card.

jQuery(document).ready(function($) { 
  if($('.slideBox_3594_standard').length > 0) { 
  } else { 
    alert('already exists'); 

Hey Krish - you can easily set the post id (for example) as a data attribute in your html - so perhaps:

<div class="entry_media" data-id="[wpv-post-id]">

in your jQuery you can easily pull the data attributes

myClass= $('.entry_media').data('id');

You could also use the id directly in your selectors:


And I think even you might get away with:

<a href="[wpv-post-url]" class='slideBox_[wpv-post-id]'></a>

Luo Yang

Languages: Englisch (English ) Vereinfachtes Chinesisch (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Dear Krish,

Does the solution of Simon works? please let me know if you need more assistance for it.


Hi Simon and Luoy, thanks for your suggestions, what I ended up doing was this:

jQuery(document).ready(function($) { 
  var id;
  $('.slidebox').each(function(i) {
    id = '.slideBox_' + $(this).data("id") + '_standard';
    if($(id).length > 0) {