Skip to content

vaniocz/jquery-ts-components

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jQuery TypeScript Components

npm install --save jquery-ts-components

Simple jQuery TypeScript component system.

// Hello.ts
import {component} from 'jquery-ts-components';

interface HelloOptions
{
    text?: string;
}

@component('HelloComponent')
export default class Hello
{
    private $element: JQuery;

    public constructor(element: JQuery | JQuery.Selector | HTMLElement, options: HelloOptions = {})    {
        this.$element = $(element);
        this.$element.text(options.text || 'Hello');
    }
}
<!doctype html>
<html lang="en">
<head>
    <meta charset=utf-8>
</head>
<body>
    <p data-component-hello-component='{"text": "Hello world!"}'></p>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="index.js"></script>
</body>
</html>
// index.ts
import {register} from 'jquery-ts-components';
import 'Hello';

register(document.body);

About

Simple jQuery TypeScript component system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published