Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Uses length validation to hide add link when you reach maximum # of nested objects#46

Open
SebastianEdwards wants to merge 1 commit into
ryanb:masterfrom
SebastianEdwards:master
Open

Uses length validation to hide add link when you reach maximum # of nested objects#46
SebastianEdwards wants to merge 1 commit into
ryanb:masterfrom
SebastianEdwards:master

Conversation

@SebastianEdwards

Copy link
Copy Markdown

Hides the add link when reaches maximum number of nested objects as defined in length validation. Ie.

class Project < ActiveRecord::Base
  has_many :tasks
  validates :tasks, :length => { :in => 1..3 }
end

Adds the attribute 'data-maximum' to the link and checks this against the number of visible nested entries on both add and remove and also on page load.

Have changed jQuery template only as am not familiar with Prototype. Probably should be altered to bind to the 'nested:fieldAdded' and 'nested:fieldRemoved' triggers.

Hope this is useful.

@ryanb

ryanb commented May 27, 2011

Copy link
Copy Markdown
Owner

Cool idea. Anyone want to add this to the prototype javascript file?

@mexxer

mexxer commented Aug 11, 2011

Copy link
Copy Markdown

Works perfectly!

What do I have to change if I want to hide the remove links for a data minimum, though?

@godalphul

Copy link
Copy Markdown

Has this been added to the most recent commit?

@avk

avk commented Oct 29, 2012

Copy link
Copy Markdown

Sad to see this wither on the vine. Would be very helpful!

@michaelglass

Copy link
Copy Markdown
Contributor

I migrated a lot of this work forward. Will be ready by EOW. Backwards compatible.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants