New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssetManager appendTimestamp not working if you use registerJsFile() #9101

Closed
otsec opened this Issue Jul 14, 2015 · 8 comments

Comments

Projects
None yet
7 participants
@otsec
Contributor

otsec commented Jul 14, 2015

Timestamp is appended only if you create your own bundle. This is too complicated if you just want to register on JS file on certain page.

registerJsFile() creates bundle inside, but does not fill the basePath. I guess this is the reason timestamp is not appended.

@saada

This comment has been minimized.

Show comment
Hide comment
@saada

saada Dec 1, 2015

Contributor

👍

Contributor

saada commented Dec 1, 2015

👍

@SilverFire SilverFire added this to the 2.0.x milestone Dec 1, 2015

@SilverFire

This comment has been minimized.

Show comment
Hide comment
@SilverFire

SilverFire Dec 1, 2015

Member

It you're feeling confident enough, feel free to send us a PR.

Member

SilverFire commented Dec 1, 2015

It you're feeling confident enough, feel free to send us a PR.

saada pushed a commit to saada/yii2 that referenced this issue Dec 1, 2015

@saada

This comment has been minimized.

Show comment
Hide comment
@saada

saada Dec 1, 2015

Contributor

My pull request
#10297

Contributor

saada commented Dec 1, 2015

My pull request
#10297

@SilverFire

This comment has been minimized.

Show comment
Hide comment
@SilverFire
Member

SilverFire commented Apr 12, 2016

@SilverFire SilverFire modified the milestones: 2.0.9, 2.0.8 Apr 26, 2016

@cebe cebe modified the milestones: 2.0.10, 2.0.9 Jul 6, 2016

@SilverFire

This comment has been minimized.

Show comment
Hide comment
@SilverFire

SilverFire Sep 10, 2016

Member

Resolved by dc23a6d

Member

SilverFire commented Sep 10, 2016

Resolved by dc23a6d

@githubjeka

This comment has been minimized.

Show comment
Hide comment
@githubjeka

githubjeka Sep 23, 2016

Contributor

Please reopen. Because #10429 (comment)

Contributor

githubjeka commented Sep 23, 2016

Please reopen. Because #10429 (comment)

@SilverFire SilverFire reopened this Sep 23, 2016

@SilverFire SilverFire modified the milestones: 2.0.x, 2.0.10 Sep 23, 2016

@SilverFire SilverFire removed their assignment Sep 23, 2016

cebe added a commit that referenced this issue Oct 20, 2016

Update CHANGELOG.md
removed reference for #9101 because the fix has been reverted.
@cronfy

This comment has been minimized.

Show comment
Hide comment
@cronfy

cronfy Dec 15, 2016

Contributor

For those who is interested in (temporary) solution:

Instead of registerJsFile() we can create new AssetBundle on the fly. Replace $this->registerJsFile($file) in your view with this code:

$file = '/js/page.js';
$asset = new \yii\web\AssetBundle([
    'js' => [ltrim($file, '/')],
    'basePath' => '@webroot',
    'baseUrl' => '/'
]);
$this->getAssetManager()->bundles[$file] = $asset;
$this->registerAssetBundle($file);
Contributor

cronfy commented Dec 15, 2016

For those who is interested in (temporary) solution:

Instead of registerJsFile() we can create new AssetBundle on the fly. Replace $this->registerJsFile($file) in your view with this code:

$file = '/js/page.js';
$asset = new \yii\web\AssetBundle([
    'js' => [ltrim($file, '/')],
    'basePath' => '@webroot',
    'baseUrl' => '/'
]);
$this->getAssetManager()->bundles[$file] = $asset;
$this->registerAssetBundle($file);
@SilverFire

This comment has been minimized.

Show comment
Hide comment
@SilverFire

SilverFire Dec 17, 2016

Member

@cronfy thank you for a good suggestion. I'm closing this issue

Member

SilverFire commented Dec 17, 2016

@cronfy thank you for a good suggestion. I'm closing this issue

@SilverFire SilverFire closed this Dec 17, 2016

@SilverFire SilverFire removed this from the 2.0.x milestone Dec 17, 2016

cebe added a commit that referenced this issue Jul 4, 2017

add notes to View register JS and CSS file methods
explain why assetmanager features are not available in these methods.

close #14382
related to #10297, #9101

tsingsun pushed a commit to tsingsun/yii2 that referenced this issue Jan 9, 2018

add notes to View register JS and CSS file methods
explain why assetmanager features are not available in these methods.

close yiisoft#14382
related to yiisoft#10297, yiisoft#9101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment