In Views when I use a conditional, math or PHP field they are assigned a set machine name with an appended number. I can't find any way to adjust/change that machine-assigned name. Views assigns them the machine names [conditional], [expression] and [php] respectively.
This causes problems in pages with attached views and/or views in blocks when using JQuery to collect field data using the DOM class. When there are multiple views on a page they can therefore have the same DOM handle (e.g., [expression_5]) even though they're distinctly different fields in different views/attached views.
For instance the field views-field-views-conditional-2 can be the field name in two different views blocks (or attachments) in the same page but be completely different fields. I need to tell them apart in JQuery.
Can anyone suggest a way to differentiate the same field handle from different views on the same page?
Comments
Normally you can add custol
Normally you can add custol class in the field display setting, and you can help you with jquery selector.
Resolved
Thank you. I Couldn't change the machine name, but adding a custom class name in the View field UI as you suggested gave me a selector I couls use to exclude using the
.not()function in JQuery. So the following.foreachstatementjQuery('.views-field-views-conditional-2').not('.my_custom_flag').each(function(){ ...Allows me to sum all
'.views-field-views-conditional-2'columns as before excluding those I gave the custom class flag to. Exactly what I needed.Thank you!