當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。