当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript client.bindHandlers函数代码示例

本文整理汇总了TypeScript中@servicestack/client.bindHandlers函数的典型用法代码示例。如果您正苦于以下问题:TypeScript bindHandlers函数的具体用法?TypeScript bindHandlers怎么用?TypeScript bindHandlers使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bindHandlers函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: bootstrapForm

import {bindHandlers, bootstrapForm, splitOnFirst, toPascalCase} from "@servicestack/client";
import {AuthenticateResponse} from "../../dtos";

bootstrapForm(document.querySelector('form'), {
    success: (r:AuthenticateResponse) => {
        location.href = '/validation/client-ts/';
    }
});

bindHandlers({
    newUser: (u: string) => {
        const $ = (sel:string) => document.querySelector(sel) as HTMLInputElement;

        const names = u.split('@');
        $("[name=displayName]").value = toPascalCase(names[0]) + " " + toPascalCase(splitOnFirst(names[1],'.')[0]); 
        $("[name=email]").value = u;
        $("[name=password]").value = $("[name=confirmPassword]").value = 'p@55wOrd';
    }
});
开发者ID:Formator,项目名称:ServiceStack,代码行数:19,代码来源:register.ts

示例2: bootstrap

import {bindHandlers, bootstrap} from "@servicestack/client";

bootstrap(); //converts data-invalid attributes into Bootstrap v4 error messages.

bindHandlers({
    switchUser: (u: string) => {
        (document.querySelector("[name=userName]") as HTMLInputElement).value = u;
        (document.querySelector("[name=password]") as HTMLInputElement).value = 'p@55wOrd';
    }
});
开发者ID:Formator,项目名称:ServiceStack,代码行数:10,代码来源:login.ts

示例3: JsonServiceClient

const client = new JsonServiceClient();

const form = document.querySelector("form")!;
bootstrapForm(form,{
    success: function (r:{result:Contact}) {
        form.reset();
        CONTACTS.push(r.result);
        render();
    }
});
bindHandlers({
    deleteContact: async function(id:number) {
        if (!confirm('Are you sure?'))
            return;

        await client.delete(new DeleteContact({ id }));
        const response = await client.get(new GetContacts());
        CONTACTS = response.results;
        render();
    }
});

const contactRow = (contact:Contact) =>
    `<tr style="background:${contact.color}">
        <td>${contact.title} ${contact.name} (${contact.age})</td>
        <td><a href="/validation/client-ts/contacts/${contact.id}/edit">edit</a></td>
        <td><button class="btn btn-sm btn-primary" data-click="deleteContact:${contact.id}">delete</button></td>
    </tr>`;

function render() {
    let sb = "";
开发者ID:Formator,项目名称:ServiceStack,代码行数:31,代码来源:index.ts


注:本文中的@servicestack/client.bindHandlers函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。