Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.3
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
27 Mar 2009 at 17:46 UTC
Updated:
21 Feb 2010 at 01:00 UTC
Hey guys,
I changed my rewrite output to a textarea, and I'm trying to use some javascript in there, but the script tags are removed in the theme. Any ideas?
Comments
Comment #1
merlinofchaos commentedUnfortunately, if you want ot put javascript in you'll have to theme the field instead. Javascript is stripped out for security reasons, and this policy is quite strict about that.
Comment #2
bgnm2000 commentedI dont understand why, if only the admins can use the views creator.
Anyway, how I can I theme just the field?
Comment #3
bgnm2000 commentedthe view name is Reviewers, and the and the field is "field_rating"
should the template file be, "views-view-field-field_rating-Reviewers.tpl.php" or "views-view-field-field-rating-Reviewers.tpl.php" because I've cleared the template registry and neither one of those templates seemed to work
Comment #4
dawehnerif theme informations suggest one, create this exact file.
then upload the file and rescan the template registry, this will help you
Comment #6
schedal commentedHello, similar problem, so I think it makes sense to tag on my issue to this one.
Only in my case, it is a little more complicated, because I need to have some javascript in the output, but I also need to use one of the tokens as part of what is rendered w/i the js..., so I can't just use the template file for this, as the token will not be passed to the template [as far as I know...?]
grouped field:
The reason I am using "onclick" is because the accordion function does not allow normal use of the href tag, as it intercepts it at the "menuBinder" level and the url request of the image click is never activated.
So, I'm trying to find a work around, by using some js inside of the grouped-title field, but now Views is blocking me as well... ug!
Any ideas? thanks.
Comment #7
merlinofchaos commentedI believe you can duplicate "onclick" by putting this javascript in a .js file in your theme that is included via the 'scripts' directive in your .info file:
Now, you have the problem that you'll need to store the nid somewhere. The easiest thing to do is to add the nid to the ID on the a tag, and use javascript's replace() method to strip it down. So add id="infobutton-[nid_1]" and then you've got your nid by getting doing
var nid = $(this).attr('id').replace('infobutton-', '');Comment #8
schedal commentedThanks Merlin, this worked great in my sitaution! And I didn't even need to capture the ID.