Stay organized with collections
Save and categorize content based on your preferences.
blockly > Block > initModel
Block.initModel() method
Call initModel on all fields on the block. May be called more than once. Either initModel or initSvg must be called after creating a block and before the first interaction with it. Interactions include UI actions (e.g. clicking and dragging) and firing events (e.g. create, delete, and change).
Signature:
initModel(): void;
Returns:
void
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["\u003cp\u003eThe \u003ccode\u003einitModel()\u003c/code\u003e method initializes the data model for a block, including its fields.\u003c/p\u003e\n"],["\u003cp\u003eThis method must be called before any user interaction with the block, such as clicking, dragging, or triggering events.\u003c/p\u003e\n"],["\u003cp\u003eIt is essential to call either \u003ccode\u003einitModel()\u003c/code\u003e or \u003ccode\u003einitSvg()\u003c/code\u003e after block creation to prepare it for use within Blockly.\u003c/p\u003e\n"],["\u003cp\u003eCalling \u003ccode\u003einitModel()\u003c/code\u003e multiple times is allowed.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [Block](./blockly.block_class.md) \\\u003e [initModel](./blockly.block_class.initmodel_1_method.md)\n\nBlock.initModel() method\n------------------------\n\nCall initModel on all fields on the block. May be called more than once. Either initModel or initSvg must be called after creating a block and before the first interaction with it. Interactions include UI actions (e.g. clicking and dragging) and firing events (e.g. create, delete, and change).\n\n**Signature:** \n\n initModel(): void;\n\n**Returns:**\n\nvoid"]]