Skip to content
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

Use of jquery 2 in Yii2 #1905

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

Use of jquery 2 in Yii2 #1905

dilip-vishwa opened this issue Jan 11, 2014 · 17 comments
Assignees
Milestone

Comments

@dilip-vishwa
Copy link
Contributor

@dilip-vishwa 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
Copy link
Member

@cebe 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
Copy link
Member

@qiangxue qiangxue commented Jan 11, 2014

Also need to check JUI.

@ghost ghost assigned samdark Jan 12, 2014
@samdark
Copy link
Member

@samdark samdark commented Jan 12, 2014

I'll handle it.

@samdark samdark closed this in c522fff Jan 12, 2014
@cebe
Copy link
Member

@cebe 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
Copy link
Contributor

@djfly 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
Copy link
Contributor

@creocoder 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
Copy link
Member

@cebe 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
Copy link
Contributor Author

@dilip-vishwa dilip-vishwa commented Jan 13, 2014

@creocoder That's nice 👍

@hallerma
Copy link

@hallerma hallerma commented 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..)

@qiansen1386
Copy link
Contributor

@qiansen1386 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
Copy link
Member

@cebe cebe commented Jan 21, 2014

@qiangxue
Copy link
Member

@qiangxue qiangxue commented Jan 21, 2014

Good job!

qiansen1386 pushed a commit to qiansen1386/yii2 that referenced this issue Mar 9, 2014
@Sammaye
Copy link

@Sammaye 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
Copy link
Member

@cebe 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
Copy link

@Sammaye 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
Copy link

@Sammaye 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
Copy link
Member

@cebe 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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants
You can’t perform that action at this time.