mirror of
https://github.com/jgthms/bulma
synced 2026-03-21 04:34:30 -07:00
Docs: Add JavaScript filename example
Embedding it directly into the docs is better than an external jsfiddle, especially since the code snippet is so simple.
This commit is contained in:
committed by
Jeremy Thomas
parent
a956873909
commit
cfcd7d124a
@@ -459,6 +459,35 @@ meta:
|
|||||||
</div>
|
</div>
|
||||||
{% endcapture %}
|
{% endcapture %}
|
||||||
|
|
||||||
|
{% capture file_javascript %}
|
||||||
|
<div id="file-js-example" class="file has-name">
|
||||||
|
<label class="file-label">
|
||||||
|
<input class="file-input" type="file" name="resume">
|
||||||
|
<span class="file-cta">
|
||||||
|
<span class="file-icon">
|
||||||
|
<i class="fas fa-upload"></i>
|
||||||
|
</span>
|
||||||
|
<span class="file-label">
|
||||||
|
Choose a file…
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span class="file-name">
|
||||||
|
No file uploaded
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const fileInput = document.querySelector('#file-js-example input[type=file]');
|
||||||
|
fileInput.onchange = () => {
|
||||||
|
if (fileInput.files.length > 0) {
|
||||||
|
const fileName = document.querySelector('#file-js-example .file-name');
|
||||||
|
fileName.textContent = fileInput.files[0].name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% endcapture %}
|
||||||
|
|
||||||
{% capture file_sizes_boxed_name %}
|
{% capture file_sizes_boxed_name %}
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="file is-small is-boxed has-name">
|
<div class="file is-small is-boxed has-name">
|
||||||
@@ -725,9 +754,9 @@ meta:
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
<p>
|
<p>
|
||||||
A file upload input requires JavaScript to <strong>retrieve</strong> the <strong>selected file name</strong>.
|
A file upload input requires JavaScript to <strong>retrieve</strong> the <strong>selected file name</strong>.
|
||||||
<br>
|
Here is an example of how this could be done:
|
||||||
User <a href="https://github.com/chintanbanugaria"><strong>@chintanbanugaria</strong></a> on GitHub <a href="https://github.com/jgthms/bulma/issues/280#issuecomment-294099510">has provided</a> a simple solution <a href="https://jsfiddle.net/chintanbanugaria/uzva5byy/">on JSFiddle</a>.
|
|
||||||
</p>
|
</p>
|
||||||
|
{% include elements/snippet.html content=file_javascript %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% include elements/variables.html
|
{% include elements/variables.html
|
||||||
|
|||||||
Reference in New Issue
Block a user