Skip to Main Content
Mastering TypeScript 3 - Third Edition
book

Mastering TypeScript 3 - Third Edition

by Nathan Rozentals
February 2019
Beginner content levelBeginner
694 pages
18h 4m
English
Packt Publishing
Content preview from Mastering TypeScript 3 - Third Edition

Backbone forms

Now that we have the base Backbone application up and running, we can make a few tweaks to include a form at the bottom of the page, and show how to get and set form values within our View. This form will be handled by the ItemCollectionView class and, as such, we will need to update our model with a new property, as follows:

class ItemCollectionViewModel extends Backbone.Model 
    implements IItemCollectionViewModel { 
 
    ... existing properties  
 
    set Name(value: string) { 
        this.set('Name', value); 
    } 
    get Name() { 
        return this.get('name'); 
    } 
 
    ... existing constructor 
 
} 

Here, we have simply added a matching pair of ES5 get and set functions to store and retrieve our Name property. Once this change is made, we will also need to set this ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The TypeScript Workshop

The TypeScript Workshop

Ben Grynhaus, Jordan Hudgens, Rayon Hunte, Matt Morgan, Wekoslav Stefanovski

Publisher Resources

ISBN: 9781789536706Supplemental Content