Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8676455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:12:07+00:00 2026-06-12T20:12:07+00:00

Basically what I’m trying to do is add a line of javascript code to

  • 0

Basically what I’m trying to do is add a line of javascript code to each row iteration in a view.

In Drupal 6 this used to be accomplished with Views Custom Field which has now been integrated into Drupal 7.

When I try to use the “Global: Custom text” field it strips out my script tags.

Any ideas?

Please note: I don’t want to use drupal_add_js as this needs to be dynamically inserted and I’d prefer to not use it inline (messy). A unique tooltip will popup based on the JS provided and I need the actual row ID.

Thanks in Advance!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:12:09+00:00Added an answer on June 12, 2026 at 8:12 pm

    Responded on Twitter, but for the benefit of others who run into the same situation (and for the sake of clarifying) I thought I’d repost here.

    Generally, I wouldn’t recommend views_php – there are numerous downsides to enabling/using PHP filters that have already been discussed at length, and it adds the bloat of another module when you really don’t need it. You can still use drupal_add_js() in a preprocess function in this case and keep things plenty dynamic.

    In short, you have a list of elements that you need to bind the same event to. Event delegation immediately comes to mind as a possible solution. Instead of n event handlers, you now have one for your parent container, which will make your page more responsive. You don’t need jQuery for this, but if you prefer look into using .delegate()

    As for how to get the ID from this external JS file, simple: make sure it’s in the source markup you’re grabbing. Assuming you’re looking for the row ID, you can typically find it in the class “views-row-N” for each row. Otherwise, you’ll want to add the class-id to the template by some other means. Inside the event handler for the target element (your row, an element matching .views-row within your parent element), parse the ID from the class you intend to use and execute the rest of your script based on the value you find from there.

    This approach has a number of benefits: it’s one less module, it’s one less source of security headaches, your JS is all in one place, you’re binding fewer event handlers, your markup is lighter and easier to read, and event delegation means this technique will still work even if elements are added to the DOM dynamically later for some reason. As for the specifics, it would help to know exactly what you intend to do with the popup. Is it making an AJAX call to another node? Is it doing something based on the position in the list? I’d be happy to clarify my answer from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
Basically I am trying to do this: <Trigger Property=Item Value={c:CollectionView.NewItemPlaceHolder}> But the syntax is
Basically I'm attempting to add rows to a table, I need to do this
Basically, I've seen this used all to often: public event MyEventHandler MyEvent; private void
Basically, I have a list of delivery checkboxes one for deliver to this address
Basically I am writing a simple bit of code to increment every one second
Basically this function is meant to store the height value of the element that
Basically what I am after is this, var foo = 'I am foo!'; alert(window['foo']);
Basically everyone writing about member enumeration in JavaScript heavily advocates the use of the
Basically I am wondering about having this behavior in an app where the newer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.