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

merlinofchaos’s picture

Status: Active » Fixed

Unfortunately, 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.

bgnm2000’s picture

I dont understand why, if only the admins can use the views creator.

Anyway, how I can I theme just the field?

bgnm2000’s picture

Status: Fixed » Active

the 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

dawehner’s picture

Status: Active » Fixed

if theme informations suggest one, create this exact file.

then upload the file and rescan the template registry, this will help you

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

schedal’s picture

Title: Javascript in rewrite output » Javascript + tokens together: in rewrite output
Status: Closed (fixed) » Active

Hello, 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:

<div class="menuBinder"><h3><a href="#">[field_menu_title_value]</a></h3><a class="infoButtonHREF" href="#" onclick="openURL(module-info/[nid_1]);"><img src="sites/all/themes/mobile_va/mobile_img/info.png" class="infobutton"/></a></div>

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.

merlinofchaos’s picture

Status: Active » Fixed

I 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:

$('a.infobutton').click(function () {
}

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-', '');

schedal’s picture

Thanks Merlin, this worked great in my sitaution! And I didn't even need to capture the ID.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.