I created a brand new module with a template in it:
which incorporates a kind:
<kind motion="<?php echo $block->getFormAction() ?>" technique="put up"> <choose id="model" title="model" kind="textual content"> <?php foreach ($block->getBrands() as $model) : ?> <choice worth="<?php echo $brand->getTitle(); ?>"><?php echo $brand->getTitle(); ?></choice> <?php endforeach; ?> </choose> <choose id="mannequin" title="mannequin" kind="textual content" disabled></choose> <choose id="yr" title="yr" kind="textual content" disabled></choose> <enter kind="submit" worth="Search" disabled> </kind>
Now I wish to add the next:
Occasions for all fields: so when model is chosen or modified an AJAX Request is being despatched to the server, loading all accessible fashions from the database relying on the chosen model including these as choices and allow the choose enter
When mannequin is being chosen or modified load all accessible years from the database add the choices and allow the enter
In Magento 1 I might have simply added all of the JS within the template file.
However I assume this isn’t good apply?
How do I resolve this in Magento 2?
I added a
view/frontend/js inside my module dir however I do not know learn how to add all of the features into this file (examples I discovered solely appear to implement one operate per file) and cargo them accurately utilizing requirejs.
What could be good apply so as to add this?