0

I'm trying to use jquery in a form of mine that is rendered via the form api.

How i'm getting jquery to work now is like so

$form['raf_raffle_name'] = array(
    '#type' => "textfield",
    "#prefix" => "<h5>Raffle information</h5><hr>",
    "#title" => "Raffle Name:",
    "#required" => TRUE,
    "#attached" => array(
        'js' => array(
            "$path/jquery.js", "$path/test1.js"
        ),
    )
);

well it works, but i'm not sure if its the right way. Is there a better way? I'm inclined to ask after i saw the 'library' attribute which is supposed to load up certain javascript plugins.

0

1 Answer 1

2

You should not have to manually include jQuery:

"When JavaScript is added to a page through Drupal, jQuery is automatically added to the page."

-- https://www.drupal.org/node/171213

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.