Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default option for data-disable-with #299

Closed
abitdodgy opened this issue Dec 19, 2012 · 7 comments
Closed

Default option for data-disable-with #299

abitdodgy opened this issue Dec 19, 2012 · 7 comments

Comments

@abitdodgy
Copy link

Would it be useful to have a default option for data-disable-with?

More often than not I need to disable buttons using their default text. The visual feedback is provided through CSS, so I don't need to change the button text.

It is possible to have a data-disable-with-default option? This would clean up some repetition in the view code, especially when translating button text.

So instead of this:

= f.submit "Create Foo", 'data-disable-with' => "Create Foo"

We could have:

= f.submit "Create Foo", 'data-disable-with-default' => true

... or something along those lines.

@neerajsingh0101
Copy link

@abitdodgy I think the solution is simple enough that it does not warrant a change in jquery-ujs. Even if this feature is there in jquery-ujs in my opinion most of the people would continue to use the old style.

@abitdodgy
Copy link
Author

Can I make another case for this?

Say you are using a form partial for the create and update actions. You can't customise the disable message without putting unnecessary conditionals:

- if @resource.new_record?
  f.submit "Create", 'data-disable-with' => 'Create'
- else
  f.submit "Update", 'data-disable-with' => 'Update'

Having this option would let us do this:

f.submit ..., 'data-disable-with-default' => true

Am I the only one who sees this as something useful? Am I missing something?

@abitdodgy
Copy link
Author

To get around this, you can have the same disable with message for both the create and update actions, but that's not very flexible, and has the side effect of resizing buttons to fit the width of the new text, pulling or pushing things out of the way.

I just think this is better:

f.submit 'data-disable-with-default' => true

Than this:

- if @resource.new_record?
  f.submit "Create", 'data-disable-with' => t(...)
- else
  f.submit "Update", 'data-disable-with' => t(...)

If I'm missing something and there's an easier way, please enlighten me.

@daniel-rikowski
Copy link

@abitdodgy It think this would be a very useful feature.

I too can't understand why anybody would not want that feature. Is nobody using disable-with with the original text or does everybody create their buttons in the manner @abitdodgy described?

@abitdodgy
Copy link
Author

@daniel-rikowski this issue has moved to #329 - it still doesn't seem to be getting any love, though.

@lucasmazza
Copy link
Contributor

#347 has a possible alternative to this, feel free review it so we can get it merged anytime soon 😄

@daniel-rikowski
Copy link

I tried it out this morning. Definitely a nice feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants