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

Bootstrap checkbox buttons hidden status after page refresh #13875

Closed
ghost opened this issue Jun 19, 2014 · 14 comments
Closed

Bootstrap checkbox buttons hidden status after page refresh #13875

ghost opened this issue Jun 19, 2014 · 14 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Jun 19, 2014

I have a form with checkbox toggle buttons (using twitter bootstrap and Rails)

<div class="btn-group" data-toggle="buttons">
  <label class="btn btn-primary">
    <input type="checkbox"> Option 1
  </label>
  <label class="btn btn-primary">
    <input type="checkbox"> Option 2
  </label>
</div>

I click and choose Option 1. Then I refresh the page. When the page is refreshed all the buttons are reset and Option 1 is not selected any more. However if I go ahead and submit the form, Option 1 is sent to the server as if it was selected (checked). Is this a bug? Is this because of something in cookie. If yes, how can I check the cookie and find the ones that should be pressed and the command to change their status to pressed.

I have text fields (<input type='text'>) in the form also. If I write in the text fields and refresh the page, the texts stay. It seems somewhere behind the scenes the state of the buttons stay as checked, too, but on the display I see them as un-checked. Therefore although the checkbox buttons seem to be un-checked when I submit the form they get submitted as checked.

Thanks a lot.

@hnrch02
Copy link
Collaborator

hnrch02 commented Jun 19, 2014

Are you using Firefox?

@hnrch02
Copy link
Collaborator

hnrch02 commented Jun 19, 2014

If that is the case, this is documented:

Cross-browser compatibility

Firefox persists the disabled state across page loads. A workaround for this is to use autocomplete="off".

@cvrebert
Copy link
Collaborator

Although that only mentions disabledness, not checkedness.

@hnrch02
Copy link
Collaborator

hnrch02 commented Jun 19, 2014

Yeah, just saw that. Testing out if it is also the case with checkedness.

@hnrch02
Copy link
Collaborator

hnrch02 commented Jun 19, 2014

Yes, that is the case. Maybe we should move that callout and change the copy.

@cvrebert
Copy link
Collaborator

Should also test Chrome just to verify that this is the Firefox-specific problem.

@hnrch02
Copy link
Collaborator

hnrch02 commented Jun 19, 2014

Chrome
(That is Chrome, FYI)

@cvrebert cvrebert added the docs label Jun 19, 2014
@cvrebert cvrebert added this to the v3.2.1 milestone Jun 19, 2014
@mdo
Copy link
Member

mdo commented Jun 19, 2014

So we need to update that callout?

@hnrch02
Copy link
Collaborator

hnrch02 commented Jun 19, 2014

Yes, because Firefox persists pretty much any form state across page loads, not only disabledness.

@ghost
Copy link
Author

ghost commented Jun 19, 2014

Thank you very much for your responses. Yes, I am using Firefox. Let me read the link you sent and see if it works for me. Really appreciate it.

@ghost
Copy link
Author

ghost commented Jun 20, 2014

Following worked for me. It resets the buttons after page refresh:

$(document).ready('bootstrap_buttons', function() {
  $('.btn').button('reset');
});

@ghost ghost closed this as completed Jun 20, 2014
@mdo mdo modified the milestones: v3.2.1, v3.2.0 Jun 20, 2014
@mdo
Copy link
Member

mdo commented Jun 20, 2014

Docs change made, called out all form control states.

mdo added a commit that referenced this issue Jun 20, 2014
@cvrebert
Copy link
Collaborator

@mdo Perhaps we should consider actually using autocomplete="off" in those examples?

@cvrebert
Copy link
Collaborator

cvrebert commented Sep 4, 2014

X-Ref: #793

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

No branches or pull requests

3 participants