Use of jquery 2 in Yii2 #1905

Closed
dilip-vishwa opened this Issue Jan 11, 2014 · 17 comments

Comments

Projects
None yet
9 participants
@dilip-vishwa
Contributor

dilip-vishwa commented Jan 11, 2014

As bootstrap has removed the support for old IE browser.

So, we should use the latest jquery version and all other latest library also.

@cebe

This comment has been minimized.

Show comment
Hide comment
@cebe

cebe Jan 11, 2014

Member

Yeah currently our composer.json restricts jquery version to 1.10.*.
We should at least change the composer json so that people can specify the version they need:

        "yiisoft/jquery": "~1.10 | ~2.0",

We need to make sure yii's javascript is compatible with all the versions.

PS: docs about ~ http://getcomposer.org/doc/01-basic-usage.md#next-significant-release-tilde-operator-

Member

cebe commented Jan 11, 2014

Yeah currently our composer.json restricts jquery version to 1.10.*.
We should at least change the composer json so that people can specify the version they need:

        "yiisoft/jquery": "~1.10 | ~2.0",

We need to make sure yii's javascript is compatible with all the versions.

PS: docs about ~ http://getcomposer.org/doc/01-basic-usage.md#next-significant-release-tilde-operator-

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 11, 2014

Member

Also need to check JUI.

Member

qiangxue commented Jan 11, 2014

Also need to check JUI.

@ghost ghost assigned samdark Jan 12, 2014

@samdark

This comment has been minimized.

Show comment
Hide comment
@samdark

samdark Jan 12, 2014

Member

I'll handle it.

Member

samdark commented Jan 12, 2014

I'll handle it.

@samdark samdark closed this in c522fff Jan 12, 2014

@cebe

This comment has been minimized.

Show comment
Hide comment
@cebe

cebe Jan 12, 2014

Member

we should not force 2.0 as it is now, as someone might need the IE compatibility.
We could specify version constraint as follows: "~2.0 | ~1.10". this should install 2.0 by default but allow requiring a lower version in app if IE compatibility is needed.

yii should only require versions that are necessary to make yii.js work.
app can fix it to a specific version if needed.

Will check whether this works and add documentation.

Member

cebe commented Jan 12, 2014

we should not force 2.0 as it is now, as someone might need the IE compatibility.
We could specify version constraint as follows: "~2.0 | ~1.10". this should install 2.0 by default but allow requiring a lower version in app if IE compatibility is needed.

yii should only require versions that are necessary to make yii.js work.
app can fix it to a specific version if needed.

Will check whether this works and add documentation.

@cebe cebe reopened this Jan 12, 2014

@ghost ghost assigned cebe Jan 12, 2014

@djfly

This comment has been minimized.

Show comment
Hide comment
@djfly

djfly Jan 13, 2014

Contributor

+1
I need jquery1.10 Because ie8
I think the default should be jquery1.10

when somebody need jquery2.0 He can switch jquery2.0

Contributor

djfly commented Jan 13, 2014

+1
I need jquery1.10 Because ie8
I think the default should be jquery1.10

when somebody need jquery2.0 He can switch jquery2.0

@creocoder

This comment has been minimized.

Show comment
Hide comment
@creocoder

creocoder Jan 13, 2014

Contributor

@djfly Logic to have always newer version by default is better. So the better say if somebody need 1.10 he can switch. From newer to older version. But not vise versa.

Contributor

creocoder commented Jan 13, 2014

@djfly Logic to have always newer version by default is better. So the better say if somebody need 1.10 he can switch. From newer to older version. But not vise versa.

@cebe

This comment has been minimized.

Show comment
Hide comment
@cebe

cebe Jan 13, 2014

Member

@djfly Logic to have always newer version by default is better. So the better say if somebody need 1.10 he can switch. From newer to older version. But not vise versa.

yep, thats the plan.

Member

cebe commented Jan 13, 2014

@djfly Logic to have always newer version by default is better. So the better say if somebody need 1.10 he can switch. From newer to older version. But not vise versa.

yep, thats the plan.

@dilip-vishwa

This comment has been minimized.

Show comment
Hide comment
@dilip-vishwa

dilip-vishwa Jan 13, 2014

Contributor

@creocoder That's nice 👍

Contributor

dilip-vishwa commented Jan 13, 2014

@creocoder That's nice 👍

@hallerma

This comment has been minimized.

Show comment
Hide comment
@hallerma

hallerma Jan 14, 2014

Bootstrap 3.0.3 requires jquery >=1.9.0 (see https://github.com/twbs/bootstrap/blob/master/bower.json ) and still supports IE8 (see http://getbootstrap.com/getting-started/#browsers )

Maybe there is a good reason why yii wants to require (not recommend) a newer version of jquery than Bootstrap.
Imho ">=1.9.0" in composer.json were correct.
The documentation can recommend >=2.0 anyway (if the browser support is sufficient).
(But I am no composer expert, I was just wondering..)

Bootstrap 3.0.3 requires jquery >=1.9.0 (see https://github.com/twbs/bootstrap/blob/master/bower.json ) and still supports IE8 (see http://getbootstrap.com/getting-started/#browsers )

Maybe there is a good reason why yii wants to require (not recommend) a newer version of jquery than Bootstrap.
Imho ">=1.9.0" in composer.json were correct.
The documentation can recommend >=2.0 anyway (if the browser support is sufficient).
(But I am no composer expert, I was just wondering..)

@qiansen1386

This comment has been minimized.

Show comment
Hide comment
@qiansen1386

qiansen1386 Jan 15, 2014

Contributor

We can use LAB.js and ie_version detection to support jquery 2 with IE fallback.

<script src="js/LAB.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        // From: http://james.padolsey.com/javascript/detect-ie-in-js-using-conditional-comments/
        var ie_version=(function(){var c,a=3,b=document.createElement('div'),d=b.getElementsByTagName('i');while(b.innerHTML='<!--[if gt IE '+(++a)+']><i></i><![endif]-->',d[0]);return a>4?a:c})();

        $LAB.setOptions({AlwaysPreserveOrder:true})
            .script(ie_version<8 ?"https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js" : '')
            .script(ie_version<8 ?"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" : '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js')
    </script>
Contributor

qiansen1386 commented Jan 15, 2014

We can use LAB.js and ie_version detection to support jquery 2 with IE fallback.

<script src="js/LAB.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        // From: http://james.padolsey.com/javascript/detect-ie-in-js-using-conditional-comments/
        var ie_version=(function(){var c,a=3,b=document.createElement('div'),d=b.getElementsByTagName('i');while(b.innerHTML='<!--[if gt IE '+(++a)+']><i></i><![endif]-->',d[0]);return a>4?a:c})();

        $LAB.setOptions({AlwaysPreserveOrder:true})
            .script(ie_version<8 ?"https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js" : '')
            .script(ie_version<8 ?"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" : '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js')
    </script>

@cebe cebe closed this in f112cc6 Jan 21, 2014

@cebe

This comment has been minimized.

Show comment
Hide comment
Member

cebe commented Jan 21, 2014

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 21, 2014

Member

Good job!

Member

qiangxue commented Jan 21, 2014

Good job!

qiansen1386 pushed a commit to qiansen1386/yii2 that referenced this issue Mar 9, 2014

@Sammaye

This comment has been minimized.

Show comment
Hide comment
@Sammaye

Sammaye Jun 25, 2014

Are you sure this was such an awesome idea, especially if some of Yii2 code specifically relies on some new feature or functionality that might be specific to 2.0? As others say, Bootstrapp 3.1.1 still supports IE8 so it seems kind of odd to provide a Jquery that breaks that support.

Sammaye commented Jun 25, 2014

Are you sure this was such an awesome idea, especially if some of Yii2 code specifically relies on some new feature or functionality that might be specific to 2.0? As others say, Bootstrapp 3.1.1 still supports IE8 so it seems kind of odd to provide a Jquery that breaks that support.

@cebe

This comment has been minimized.

Show comment
Hide comment
@cebe

cebe Jun 25, 2014

Member

@Sammaye you can choose a jquery version for yourself by defining it explicitly in composer.json. The default is the latest version.
http://stuff.cebe.cc/yii2docs/guide-extend-using-composer.html#using-a-specifc-version-of-a-package

Member

cebe commented Jun 25, 2014

@Sammaye you can choose a jquery version for yourself by defining it explicitly in composer.json. The default is the latest version.
http://stuff.cebe.cc/yii2docs/guide-extend-using-composer.html#using-a-specifc-version-of-a-package

@Sammaye

This comment has been minimized.

Show comment
Hide comment
@Sammaye

Sammaye Sep 26, 2014

No matter how much I search Google and the docs I cannot find the new location of that page.

I need it now that jquery has been changed to a bower dep.

Sammaye commented Sep 26, 2014

No matter how much I search Google and the docs I cannot find the new location of that page.

I need it now that jquery has been changed to a bower dep.

@Sammaye

This comment has been minimized.

Show comment
Hide comment
@Sammaye

Sammaye Sep 26, 2014

Meh, it worked as I thought it would but still, good to link this information somewhere; I am sure there are many who will be caught out by JQuery 2.0 requirements on Yii2, especially if they intend to run a retail site.

Sammaye commented Sep 26, 2014

Meh, it worked as I thought it would but still, good to link this information somewhere; I am sure there are many who will be caught out by JQuery 2.0 requirements on Yii2, especially if they intend to run a retail site.

@cebe

This comment has been minimized.

Show comment
Hide comment
@cebe

cebe Oct 1, 2014

Member

here it is gone ;) b663007#diff-fca53aecf2232821dfe114957df0059eL117

Not sure if we should add this back somewhere, this is composer knowledge and can be looked up in composer docs. If someone has a good idea where to place it in the guide, I am open for proposals.

Member

cebe commented Oct 1, 2014

here it is gone ;) b663007#diff-fca53aecf2232821dfe114957df0059eL117

Not sure if we should add this back somewhere, this is composer knowledge and can be looked up in composer docs. If someone has a good idea where to place it in the guide, I am open for proposals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment