Relocate the preview division below the button in the Kartik File Input Widget

There are two input file buttons that allow users to upload an image on each button. Upon selecting an image, a preview of the image will be displayed above the button. The current layout is shown here:

https://i.sstatic.net/aLAbo.png

When images of different sizes are uploaded, the buttons do not align horizontally. I now want to move the buttons above the preview, with the preview placed below the button. I have attempted using jQuery like this:

$('.file-preview').insertAfter('.btn .btn-primary .btn-block .btn-file');
$('.file-preview').detach().insertAfter('.btn .btn-primary .btn-block .btn-file');

However, these methods did not work as expected. If you have any alternative suggestions, please feel free to share them in the comments or answer. Thank you.

EDIT: Below is the code snippet for the widget:

<div class="col-sm-6"><input type="hidden" name="Contact[attachment_1]" value="">
    <span class="file-input">
        <div class="file-preview">
            <div class="close fileinput-remove">×</div>
            <div class="">
                <div class="file-preview-thumbnails">
                    <div class="file-preview-frame" id="preview-1447035353917-0" data-fileindex="0">
                        <img src="blob:http%3A//localhost/0bc1d4fc-c8f8-4b7c-a963-0d3090193832" class="file-preview-image" title="Business-card-template-design.jpg" alt="Business-card-template-design.jpg" style="width:auto;height:160px;">
                        <div class="file-thumbnail-footer">
                            <div class="file-caption-name" title="Business-card-template-design.jpg" style="width: 238px;">Business-card-template-design.jpg</div>
                        </div>
                    </div>
                </div>
                <div class="clearfix"></div>   
                <div class="file-preview-status text-center text-success"></div>
                <div class="kv-fileinput-error file-error-message" style="display: none;"></div>
            </div>
        </div>
        <div class="kv-upload-progress hide">
            <div class="progress">
                <div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0%;">
                    0%
                </div>
            </div>
        </div>

        <button type="button" title="Abort ongoing upload" class="hide btn btn-default fileinput-cancel fileinput-cancel-button"><i class="glyphicon glyphicon-ban-circle"></i> Cancel</button>

        <div class="btn btn-primary btn-block btn-file"> <i class="glyphicon glyphicon-camera"></i> Attach Business Card 1 <input type="file" id="contact-attachment_1" class="" name="Contact[attachment_1]" accept="image/*" data-krajee-fileinput="fileinput_a052254a"></div>
    </span>
<!--[if lt IE 10]><br><div class="alert alert-warning"><strong>Note:</strong> Your browser does not support file preview and multiple file upload. Try an alternative or more recent browser to access these features.</div><script>jQuery("#contact-attachment_1").removeClass('file-loading');</script><![endif]-->
</div>

Answer №1

Oh, I understand now. I utilized the layoutTemplates feature and inserted "{preview}" at the end of the main2 section:

'layoutTemplates' => [
   'main2' => '<div class="kv-upload-progress hide"></div>{remove}{cancel}{upload}{browse}{preview}',
]

For more information, you can visit:

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

Material UI AppBar displaying custom colors instead of theme colors

Currently, I am utilizing Material UI version 4.7.0. In my project, I have established a customized theme (shown below) by utilizing createMuiTheme() method with personalized primary and secondary colors set. Within my AppBar component (also displayed be ...

Steps for transitioning a VUE JS project to TypeScript

Is it possible to transition a VUE JS project from JavaScript to TypeScript without rewriting everything? I heard from a friend that it can be done through the VUE CLI, but I haven't been able to find any documentation or articles on this method. Has ...

Output JSON data to an HTML5 table

Here is a code snippet to retrieve data: function fetchInformation(){ $.get('http://mywebsite.net/getFile.php', function(data) { var result = JSON.parse(data); } The returned JSON data is as follows: Object {0: "11", 1: ...

The ancient oracle of Delphi and the modern login portal of Microsoft

I need to login to a site that utilizes . To streamline the process for end-users, I want to store credentials in an .ini file and inject them into a two-stage JavaScript online prompt. Is there a way to have Delphi run a program with a browser that auto ...

Experiencing a problem with my JavaScript code in Node.js due to an asynchronous issue arising when using a timeout

My goal with this code is to retrieve JSON questions and present them to the user through the terminal. The user has 5 seconds to respond to each question before the next one appears. However, I encountered an issue where the next question times out automa ...

Encountering an issue with core.js:15723 showing ERROR TypeError: Unable to access property 'toLowerCase' of an undefined value while using Angular 7

Below, I have provided my code which utilizes the lazyLoading Module. Please review my code and identify any errors. Currently facing TypeError: Cannot read property 'toLowerCase' of undefined in Angular 7. Model Class: export class C_data { ...

Scrolling to an id within dynamically loaded content using jQuery after an ajax request

After loading content via ajax, I am unable to scroll to the item, as the page remains at the top. Strangely, when I refresh the page dynamically with content caching enabled, the page scrolls to the desired target. var startPageLoader = function( pid, si ...

troubleshooting problems with jquery ajax and setInterval

$(document).ready(function() { function refreshBids() { var element = $("#biddingDiv"); element.load("bids.php?id=<?=$userId;?>&init=1&auctionid=<?=$auctionId;?>"+(new Date()).getTime()); } refreshBids(); setI ...

Rotate the circular border in a clockwise direction when clicked

I have successfully designed a heart icon using SVG that can be filled with color upon clicking. Now, I am looking to add an outer circle animation that rotates clockwise around the heart as it is being created. Currently, the circle only spins in the code ...

Having trouble with jQuery AJAX - page continually refreshes upon submitting and data isn't being transmitted

I've been working on creating a dynamic AJAX function using PHP and MySQL to update database records without the need for page refresh or navigation. However, I haven't had much success with it yet. Here's the code I have on the page with t ...

Is there additional cushioning beneath an image within a div element?

It appears that my div containing an image has extra padding at the bottom for some unknown reason. You can view the JSFiddle here: http://jsfiddle.net/KSs7V/ Any suggestions on how this padding might have been added and how to correct it? CSS: .artist ...

Is jQuery each function always sorting the elements?

In my JavaScript code, I have a specific object: var list = {134 : "A",140 : "B",131 : "C"} To iterate over the object, I use this code snippet: jQuery.each(list, function(key, value) { console.log(key + " - " + value); }); The expected output should ...

Passport JS allows you to create a secure login form that redirects users to different URIs based on their role

Currently, I am utilizing Passport JS for authentication management and Express JS to handle routing within my application. At the moment, I have a login route that directs to the /teacher URI upon successful authentication (as depicted below). app.post( ...

Step-by-step guide to creating a transition effect when the input changes

I'm looking to add a unique effect to my dropdown menu My goal is to create an effect in which the placeholder moves up and the new value seamlessly takes its place, using JS, jQuery, CSS, and HTML. View before transition View after transition ...

What is the best way to apply a box-shadow to a specific side of an element?

How can I apply a box shadow to only the right side of a block element? Currently, I achieve this by wrapping the inner element with a box-shadow in an outer element with padding-right and overflow:hidden to hide the other three sides of the shadow. Is the ...

How to simulate loadStripe behavior with Cypress stub?

I am struggling to correctly stub out Stripe from my tests CartCheckoutButton.ts import React from 'react' import { loadStripe } from '@stripe/stripe-js' import useCart from '~/state/CartContext' import styles from '. ...

Image selection plugin in Cordova not functioning properly

Currently, I am attempting to select multiple images from the gallery using the cordova-imagePicker plugin. It's worth noting that my project uses Cordova rather than the Ionic framework. Below is the code snippet I have implemented: <script type ...

Using a div in React to create a vertical gap between two React elements

I am working with two React Components in my project - the Right Column and the Left Column. I am trying to create space between them using a div tag. Currently, my setup in the App.js file looks like this: import React from 'react'; import LeftC ...

My jQuery AJAX request is not successfully communicating with my PHP script

I am not well-versed in AJAX (or jQuery), but I believed my task was fairly straightforward. However, when attempting to send an AJAX request using: $.ajax( requestObj ); it seems to fail, and I am seeking assistance. To provide context, here is how the ...

Retrieving data from the database into a DIV using ajax

Here is the code snippet I am using to retrieve values from my database at regular intervals: <script type="text/javascript"> $(document).ready(function(){ var j = jQuery.noConflict(); j(document).ready(function() { j(".refreshMe ...