npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

marionette-fields

v0.7.0

Published

Trying to easy the form creation and maintainability of forms inside a Marionete view.

Downloads

8

Readme

Marionette Forms

Trying to easy the form creation and maintainability of forms inside a Marionette view.

Copyright

Initially, this project was copied from Ampersand form related projects. It was adapted to work with Marionette. Below are the references this code is based on.

  • https://github.com/AmpersandJS/ampersand-form-view
  • https://github.com/AmpersandJS/ampersand-input-view
  • https://github.com/AmpersandJS/ampersand-select-view
  • https://github.com/AmpersandJS/ampersand-array-input-view
  • https://github.com/AmpersandJS/ampersand-checkbox-view

Field requirements

That form can be given an array of field views.

These fields are also Marionette views, but just follow a few more conventions in order to be able to work with form view.

Those rules are as follows:

  • It has to be an instance of Marionette.View, because the fields are rendered inside a Marionette Region.
  • It has a getValue() function that returns the current value of the field.
  • It has a setValue() function that sets the current value of the field.
  • It should also store a value property if passed in as part of the config/options object when the view is created.
  • It has a isValid() function that returns a boolean. The parent form checks this to know whether it can submit the form or not.
  • It has a getName() function that returns the name of the field.
  • It reports changes to its parent when it deems appropriate by calling this.parent.update(this) **note that it passes itsef to the parent. You would typically do this when the this.value has changed or the this.valid has changed.
  • When rendered by a form-view, the form view creates a parent property that is a reference to the containing form view.
  • It can optionally also define a beforeSubmit method. This gets called by the parent if it exists. This can be useful for stuff like a required text input that you don't want to show an error for if empty until the user tries to submit the form.