Marx.js was created for developers building web applications with long forms. Marx.js is a plugin that gives the developer the ability to populate any and all the fields in their forms easily and with a small 10kb file.
Forms are populated with Marx Brother names, years of their movies and quotes from those movies.
Add this line to your application's Gemfile:
gem 'marxjs-rails'
And then execute:
$ bundle
Or install it yourself as:
$ gem install marxjs-rails
Simply add the render_marxjs helper method to your Rails layout or to any specific page you wish.
<html>
<head>...</head>
<body>
<h1>My Content</h1>
...
<%= render_marxjs %>
</body>
</html>
To add options to the Marx.js plugin, simply pass them as a Hash to the helper method:
# Switching to Haml :)
%html
%head
... omitted ...
%body
%h1 My Content
... omitted ...
= render_marxjs {controls: 'toggle-all', position: 'top-left'}
If you wish to have Marx.js in your production and/or staging environment, pass the last argument of false:
= render_marxjs {controls: 'toggle-all', position: 'top-left'}, false
| Value | Default | Description |
|---|---|---|
| controls | standard | select controls provided by MarxJS. See below for options |
| form | null | css selector of a specific form in which to effect changes on |
| position | bottom-right | top-left, top-right, bottom-right, bottom-left |
| ipsum | 3 | default number of paragraphs for the ipsum generator |
| ipsum-max | 10 | maximum paragraphs allowed to generate |
Control Options
| Value | Description |
|---|---|
| minimum | just the MarxJS button that fills out entire form. |
| standard | gives options for populate whole form or individual form field types. |
| advanced | all standard options and Clear Form, Populate and Submit, Show Hidden Fields, Expand Select Boxes and Generate Ipsum. |
| toggle-advanced | gives both standard and advanced options but hides advanced till you need them |
| toggle-all | provides buttons to populate whole form, show standard controls and show advanced controls |
Dependencies
Marx.js has a dependency on jQuery version >= 1.10.x
In version 2.x we have made it easier to include Marx.js without having to remove/alter anything when deploying to production. When upgrading from version 1.x, you will need to REMOVE the following:
//= require jquery//= marx//= require_tree . //= require_self
$ ->
marx = new Marx()
Add the following directive to your Javascript manifest file (application.js):
//= marx
Simply create a new instance of the Marx object in one of your .js.coffee files and you are up and running.
$ -> marx = new Marx()
If you wish to limit this to only one form make sure to pass the form option to the Marx object:
$ ->
marx = new Marx
form: 'form.my-form'
- Fork it ( http://github.com/Sparkmasterflex/marxjs-rails/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request