primefaces / primeng

The Most Complete Angular UI Component Library
https://primeng.org
Other
10.35k stars 4.58k forks source link

Calendar exception #92

Closed ProvoK closed 8 years ago

ProvoK commented 8 years ago

Calendar component raise an exception when used "EXCEPTION: TypeError: jQuery(...).datepicker is not a function"

html template (partial) <p-calendar [(value)]="dateValue" [inline]="true" > </p-calendar>

ts

` import { SelectItem, Calendar } from "primeng/primeng" @Component ({ selector: "register-component", templateUrl: "scripts/apps/AuthenticationApp/templates/register.component.html", directives : [Password, InputText, Fieldset, Dropdown, Calendar] }) export class RegisterComponent implements OnInit { countries: SelectItem[]; dateValue:string; constructor () {}

ngOnInit()
{
    this.countries = COUNTRIES;
}

} `

cagataycivici commented 8 years ago

Do you have jquery ui datepicker included on your page?

ProvoK commented 8 years ago

I included scripts as in yours showcase demo here's the code `

<link rel="stylesheet" type="text/css" href="scripts/resources/primeui.css" />
<script src="scripts/node_modules/es6-shim/es6-shim.min.js"></script>
<script src="scripts/node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="scripts/node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="scripts/node_modules/systemjs/dist/system.src.js"></script>

<script src="scripts/resources/jquery.js"></script>
<script src="scripts/resources/jquery-ui.js"></script>
<script src="scripts/resources/primeui.js"></script>

<script src="scripts/node_modules/rxjs/bundles/Rx.js"></script>
<script src="scripts/node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="scripts/node_modules/angular2/bundles/router.dev.js"></script>

`

ProvoK commented 8 years ago

I tried this too `

<link rel="stylesheet" type="text/css" href="scripts/resources/primeui.css" />
<script src="scripts/node_modules/es6-shim/es6-shim.min.js"></script>
<script src="scripts/node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="scripts/node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="scripts/node_modules/systemjs/dist/system.src.js"></script>

<script src="scripts/node_modules/jquery/dist/jquery.js"></script>
<script src="scripts/node_modules/jquery-ui/jquery-ui.js"></script>
<script src="scripts/node_modules/jquery-ui/datepicker.js"></script>
<script src="scripts/resources/primeui.js"></script>

<script src="scripts/node_modules/rxjs/bundles/Rx.js"></script>
<script src="scripts/node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="scripts/node_modules/angular2/bundles/router.dev.js"></script>
 `

After installing jquery and jquery-ui with npm, but now i got more errors image

cagataycivici commented 8 years ago

The ones in npm is a modified version to be used with a common loader, since you use script tags, you need the original ones, here are the links;

https://github.com/primefaces/primeng/blob/master/showcase/resources/js/jquery.js https://github.com/primefaces/primeng/blob/master/showcase/resources/js/jquery-ui.js

jquery.js is nothing special, jquery-ui.js is shrinked version that contains only what is necessary like core+datepicker. Please try with these files.

cagataycivici commented 8 years ago

Please also see;

http://blog.npmjs.org/post/112064849860/using-jquery-plugins-with-npm

ProvoK commented 8 years ago

I downloaded the new resources and now it works fine! Thanks a lot

cagataycivici commented 8 years ago

Glad to hear!

ProvoK commented 8 years ago

Thanks again for fast support. I suggest to include those resources in the npm install of primeng

cagataycivici commented 8 years ago

We've done some changes lately on primeui site of things to generate primeui-ng.css and primeui-ng.js that basically includes everything ng needs to avoid issues like this one in future. Documentation will also be updated tomorrow with 0.7.