javascript - How to use JQuery UI components in Aurelia getting started app (navigation app) -


i able run aurelia app following steps provided in getting started tutorial. have used bootstrap nav-bar in skeleton application. possible use jquery ui components in aurelia app. if yes, please explain me how achieve this.

thanks in advance.

yes, it's possible!

i've made jqueryui tabs example you:

tabs.html

<template>     <ul>       <li repeat.for="tab of tabs">         <a href="${'#' + $parent.id + '-' + $index}">${tab.title}</a>       </li>     </ul>     <div repeat.for="tab of tabs" id="${$parent.id + '-' + $index}">       <p>${tab.text}</p>     </div> </template> 

as can see, i've copied boilerplate html of jqueryui tabs component, , created bindable property tabswhich array of objects that: [{title: "", text: ""}].

tabs.js

import {bindable, inject} 'aurelia-framework'; import $ 'jquery'; import {tabs} 'jquery-ui';  @inject(element) export class tab {   @bindable tabs = null;    constructor(el) {     this.id = el.id;   }    attached() {         $(`#${this.id}`).tabs();   } } 

the code pretty readable: i've imported jquery config.js file, , jquery-ui there (only component tabs, gets lighter). then, i've injected domelement class, it's id. i've created bindable property tabs. in constructor, domelement id , populates id property. and, finally, on attached event (when binds finished), i've got jquery object id, , called method tabs() turn template tabs component. pretty simple, uh?

in config.js file, i've added 2 lines:

"jquery": "github:components/jquery@2.1.4", "jquery-ui": "github:components/jqueryui@1.11.4", 

and can use tabs component wherever want, calling in other html template of project:

that's it!

you can see working example here: http://plnkr.co/edit/esxza2jtln7f6aiq1ixg?p=preview

ps: plnkr, sylvian, i've used yours fork mine.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -