Designing the tomahawk file upload component

Attempting to customize the t:inputFileUpload element, a solution was tried from styling an input type=file. This involves adding another input element and image to occupy the same space as the t:inputFileUpload. Below is the code snippet:

<div id="file-div">
    <h:inputText styleClass="replace-upload" id="fake-input" />
        <div class="browse-img">
            <span class="browse-button">#{msgs.select}</span>
        </div>
    <t:inputFileUpload id="file" value="#{createListBean.uploadedFile}"
        size="22" accept=".xls,.xlsx,.csv" type="file" style="z-index :2;opacity:0;position:relative;"
        onchange="changeFakeFile()" styleClass="file-real" />
</div>

The styling included in the implementation:

.replace-upload {
    border: 1px solid #EEEEEE !important;
    border-radius: 3px 3px 3px 3px !important;
    box-shadow: 2px 2px 0 0 #CCCCCC inset !important;
    color: #333333 !important;
    font-size: 14px !important;
    margin-top: -5px;
    padding: 5px !important;
    width: 157px !important;
    position: absolute;
    z-index: 1;
}

.browse-img {
    background-color: #333333;
    color: #FFFFFF;
    width: 76px;
    position: absolute;
    left: 171px;
    top:-2px;
    border-radius: 3px 3px 3px 3px;
    box-shadow: 0 1px 1px #000000;
}

.browse-button {
    color:#FFFFFF;
    cursor: pointer;
    display: block;
    font-size: 12px;
    font-weight: bold;
    line-height: normal;
    padding: 5px 18px;
    text-decoration: none;
}

When the user clicks on the fake input element, they are actually interacting with the tomahawk element. However, the selected file path does not appear over the fake input. To address this issue, JavaScript function was added:

changeFakeFile(){
    var x = $('.file-real').val();
    $('.replace-upload').text(x);}

The problem arises when the fake input value changes but does not show to the user. Any suggestions on making it visible?

Answer №1

Instead of using $('.replace-upload').text(x);, I switched to $('.replace-upload').val(x); and the solution was successful.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Overlap and cover additional elements within a DIV

I am looking to create a versatile function that can effortlessly overlay various elements such as selects, textfields, inputs, divs, tables, and more with a partially transparent div matching their exact height and width. I have managed to obtain the pos ...

Having trouble with the setHours function in React not behaving as anticipated?

I'm having trouble adjusting the time in my React application using the setHours method: function App() { let currHour = new Date().setHours(15); return ( <div> <h1>{currHour}</h1> </div> ); } Inst ...

Is there a way to align the button in the middle of the dropdown menu?

I am struggling to center align a button inside a dropdown menu that I have created for signing in. https://i.sstatic.net/2O3uk.jpg <ul class="nav navbar-nav navbar-right"> <li class="dropdown text-center"> <a class="dropdown-toggle" ...

Rely on the pre-installed package

Currently, I am creating a intelligent package that relies on 'showdown', a pre-installed Meteor package. How should I indicate this dependency? Even after adding packages: { 'showdown': {} } to smart.json, I encountered an error st ...

Determine if the grid is accurately sorted in sequence using Cypress

I am currently working on sorting images based on their order, with the options for new and old. The [data-cy="list-file"] wraps all the images, while [data-cy=fileCard-list] represents each individual image. After selecting the 'old' b ...

Use JavaScript to close a modal by simulating the pressing of the "esc" key within the

Is there a way to programmatically close all modals in Javascript without having to press the escape key manually? I tried running the following code in the browser console, but it didn't work at all. Can anyone help me resolve this issue? document.di ...

Isn't it ineffective to save blockchain blocks in an array structure? (Node.js)

After researching techniques for creating a blockchain using Node.js, it seems that many articles recommend using arrays to store blocks. In my opinion, utilizing an array may not be the most efficient method, especially considering the potential size of ...

Why is my PHP function not able to properly receive the array that was sent to it via Ajax?

After retrieving an array through an ajax query, I am looking to pass it to a PHP function for manipulation and utilization of the elements at each index. The PHP function in question is as follows: class ControladorCompraEfectivoYTarjeta { public fu ...

Refresh FullCalendar in Angular 2 and above

Can someone please assist me with re-rendering or redrawing a full-calendar in Angular using @fullcalendar/resource-timeline? I have updated the data after calling the API and now I need to make sure the calendar reflects these changes. Any guidance on h ...

The scrolling feature within individual div elements seems to be malfunctioning in Ionic 2

In my current project using Ionic 2, I am faced with the task of designing a screen that contains two distinct grid views. The first grid view needs to occupy 40% of the height, allowing for scrolling within that specified area. On the other hand, the se ...

Accordion border in Bootstrap should be applied to all items except the first one

I am currently implementing Bootstrap accordions in an Angular application and I am facing an issue where I want to have a colored border all around each accordion panel. The problem is that by default, Bootstrap removes the top border from all accordions ...

The versatile aspect of my discord bot is its ability to function with various

It's pretty strange, but my bot seems to respond to different prefixes than what I originally set. Even though I specified "-"" as the prefix in my code, the bot's commands also work with other symbols like "_", ">", "?", etc. I suspect this m ...

Enhancing Google Custom Search Engine with Bootstrap3 and CSS3 styling

I'm looking for guidance on how to customize the appearance of a Google Custom Searchbar on my website. Is it feasible to style it using CSS3 and Bootstrap 3 like the example in the image below? Any assistance is greatly appreciated. ...

Adding a lone item to an array

One of the functionalities in my component allows users to toggle it on/off by clicking on it: toggleHandler = () => { this.setState({active: !this.state.active}) this.props.getSelection(this.state.active) } render() { const { key, childr ...

What's the deal with inline blocks and text in the middle?

Check out this code I created for a navigation bar. HTML : <div class="header-nav"> <div class="header"> <img src="../Pictures/LifeFrame/2.jpg" width="100%" height="100px" /> </div> <div class="nav" align="c ...

After successfully building with Vite, an error occurs stating "TypeError: can't convert undefined to object." However, during development with Vite, everything functions flawlessly

Currently, I am utilizing Vite in conjunction with React and Typescript for my project. Interestingly, when I execute 'vite dev', the live version of the website works flawlessly without any errors showing up on the console. However, things take ...

Exploring the syntax for navigating with JS Angular and HTML, such as when using the code snippet: ng-click="save(userForm)"

I am struggling to grasp the functionality of a specific part of this code. Despite my efforts to find tutorials, I have been unable to locate relevant information. There are two lines in particular that puzzle me: <button type="submit" class="btn btn ...

Having trouble retrieving files in a Django template

When attempting to download a file from a local directory within a Django template, I encounter an issue. Once I click on the download link, the file explorer opens for me to choose a folder, but when I go to save the file, I receive a File Not Found error ...

Unlocking the key to retrieving request headers in the express.static method

Utilizing express.static middleware allows me to avoid manually listing each asset in the routes. All my routing is managed through index.html due to my use of Vue JS. However, a feature necessitates me to extract specific information from the request hea ...

Tips for utilizing nested result sets with JDBC

I am in need of retrieving categories and their respective subcategories from the database in a specific format. The desired layout can be seen in the following image: ![KIDS menu where shop, help, mycompany, account, popular are main categories and labels ...