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.

EE tags inside a block of jQuery

July 10, 2011 3:58pm

Subscribe [3]
  • #1 / Jul 10, 2011 3:58pm

    bcrabtree

    60 posts

    Hi all,

    I’m trying to figure out if this is possible. I’ve tried it out and all I get is a JavaScript error.

    I would like to know if it’s possible to place EE tags inside a block of jQuery.

    Basically I’m using “Switch” and “Case” and setting variable values based on a channel entry with a Matrix field. I’m pretty sure the issue is with the Matrix loop tags wrapping my Case because my “Default: item_price =” code is working perfectly.

    Here’s my code for reference:

    {exp:channel:entries channel="store_pricing_shipping" entry_id="174"}
        [removed]
            jQuery(document).ready(function($){
                $('#size_option, #frame_option').change(function() {
                    var option = $('#size_option').val() +" "+ $('#frame_option').val(), item_price;
    
                    // set span
                    switch (option) {
    // BEGIN EE TAGS
                        '{my_matrix_field}'
                        case "{optionA} {optionB}":
                            item_price = "{item_price}";
                            shipping_price = "{shipping_cost}";
                        break;
                        '{/my_matrix_field}'
    
                        default:
                            item_price = "{my_matrix_field limit='1'}{item_price}{/my_matrix_field}";
    // END EE TAGS
                    }
    
    
                    // More jQuery
                });
            });
        [removed]
    {/exp:channel:entries}
  • #2 / Jul 10, 2011 6:42pm

    bcrabtree

    60 posts

    Never mind, I got it to work.

    Although I have no idea why or how it works… While fiddling with the code I randomly decided to just remove the Matrix tag pair entirely, and poof it works. I’m a little confused because I thought that the Matrix tag pair was required to access the fields within a Matrix field…

    Oh well, it works, so I’m happy.

  • #3 / Jul 11, 2011 12:06pm

    Sue Crocker

    26054 posts

    .. that’s the most important thing. 😉 If anything else comes up, please do let us know in a new thread..

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

ExpressionEngine News!

#eecms, #events, #releases