Rails – Update a single attribute : link with custom action or form with hidden fields?

Not sure what your routes look like but if you have an update action it should work with the link_to. If you go with the link make sure you use a method of PUT or POST (ideally PUT because it’s an update): link_to(“Unlink your facebook account”, user_path(@user, :facebook_uid => nil), :method => :put, :confirm => … Read more

application/x-www-form-urlencoded and charset=”utf-8″?

There is no charset parameter defined for this media type. For the encoding guidelines, see https://url.spec.whatwg.org/#application/x-www-form-urlencoded . The application/x-www-form-urlencoded standard implies UTF-8 and percent-encoding. Though: A legacy server-oriented implementation might have to support encodings other than UTF-8 as well as have special logic for tuples of which the name is _charset. Such logic is not … Read more

What does Bootstrap’s control-label class do?

The control-label class is useful for validation states, that’s why we need it in all labels even the fields bootstrap’s documentation doesn’t mention. We can see it in the bootstrap source code when it is defining the has-success, has-warning, etc classes: https://github.com/twbs/bootstrap/blob/bfb99413eefbbe2e8fbb1e477cbfa63ea7d36140/dist/css/bootstrap-rtl.css#L3242 As you can see, it uses the control-label class not the label element. … Read more

jQuery – Send a form asynchronously

$(‘form[name=contact]’).submit(function(){ // Maybe show a loading indicator… $.post($(this).attr(‘action’), $(this).serialize(), function(res){ // Do something with the response `res` console.log(res); // Don’t forget to hide the loading indicator! }); return false; // prevent default action }); See: jQuery docs: post jQuery docs: serialize

How can I insert a Print button that prints a form in a webpage

Print the whole page Try adding a button that calls window.print() <input type=”button” value=”Print this page” onClick=”window.print()”> Print a specific portion/container in a page <div id=”print-content”> <form> <input type=”button” onclick=”printDiv(‘print-content’)” value=”print a div!”/> </form> </div> then in the HTML file, add this script code <script type=”text/javascript”> function printDiv(divName) { var printContents = document.getElementById(divName).innerHTML; w=window.open(); w.document.write(printContents); … Read more