HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

AddJsFile() with no version arg

ddumontddumont ✭✭
Is there a way to use the AddJsFile() method of the controller class and have it not append the vanilla version to the script url as a url arg?

There was an error rendering this rich post.

Tagged:

Best Answer

  • ddumontddumont ✭✭
    edited June 2011 Answer ✓
    // Normally one would use ->AddJsFile or ->Head->AddScript, 
    // but these insert a version arg in the url that might make the request invalid.
    $Sender->Head->AddTag('script', array(
    // This last FALSE is the important bit
    'src' => Asset('http://script.file.here.js"), FALSE, FALSE),
    'type' => 'text/javascript')
    );

    There was an error rendering this rich post.

Answers

  • ddumontddumont ✭✭
    edited June 2011 Answer ✓
    // Normally one would use ->AddJsFile or ->Head->AddScript, 
    // but these insert a version arg in the url that might make the request invalid.
    $Sender->Head->AddTag('script', array(
    // This last FALSE is the important bit
    'src' => Asset('http://script.file.here.js"), FALSE, FALSE),
    'type' => 'text/javascript')
    );

    There was an error rendering this rich post.

  • It appears that I cannot answer my own question... :( Can an admin mark this answered?

    There was an error rendering this rich post.

  • ToddTodd Vanilla Staff
    Sure thing! I don't think you need the Asset() call around full urls.
  • Was just following what the code was doing :) Good to know though.

    There was an error rendering this rich post.

Sign In or Register to comment.