ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to use EE variables within a jquery function?

August 01, 2008 1:36pm

Subscribe [2]
  • #1 / Aug 01, 2008 1:36pm

    jducka1

    12 posts

    I am trying to create a dynamic image swap with jquery.  My image src is in a custom field in a related entry.  For each image I have a title_image_file (default state) and a title_image_file_mo (hover state).  (I’m not sure if this is relevant, but the image entry is associated with the current entry via a related_entry). The problem is the EE tags within my jquery aren’t being parsed. 

    My jquery:

    $('img.title').hover(function(){
                $(this).attr("src","{title_image_file_mo}");
                },function(){
                    $(this).attr("src","{title_image_file}");
                });


    My HTML:

    {exp:weblog:entries weblog="default_site" dynamic="off" orderby="custom_sort" sort="asc" search:page_no="p1" category="{cat_id}"}
    
    <li><a href="http://{path=h1/product/{entry_id}}">_    {related_entries id="title_image"}_       {title_image_file}_    {/related_entries}</a></li>
    
    {/exp:weblog:entries}

    The jQuery *is* working because when I hover over the image it is replaced by a broken image link (i.e., the contents of the alt tag). 

    Help!?!

  • #2 / Aug 01, 2008 7:46pm

    Sean C. Smith

    3818 posts

    are you putting the jquery code before the closing {/exp:weblog:entries} tag?

    also can you provide a link to the page where you are having problems.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases