modal div doesn't show when included within a php file - php

when i include a agenda.php file that contains a div with bootstrap modal class inside a div in another php file, it doesn't show properly.
agenda.php
<style type="text/css">
.block a:hover{
color: silver;
}
.block a{
color: #fff;
}
.block {
position: fixed;
background: #2184cd;
padding: 20px;
z-index: 1;
top: 240px;
}
</style>
<!-- Place this tag where you want the badge to render. -->
<br /><br />
<hr />
<!--<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js" crossorigin="anonymous"></script>
<link href="css/bootstrap.min.css" rel="stylesheet" >
-->
<!-- add calander in this div -->
<div class="container">
<div class="row">
<div id="calendar"></div>
</div>
</div>
<!-- Modal -->
<div id="createEventModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add Event</h4>
</div>
<div class="modal-body">
<div class="control-group">
<label class="control-label" for="inputPatient">Event:</label>
<div class="field desc">
<input class="form-control" id="title" name="title" placeholder="Event" type="text" value="">
</div>
</div>
<input type="hidden" id="startTime"/>
<input type="hidden" id="endTime"/>
<div class="control-group">
<label class="control-label" for="when">When:</label>
<div class="controls controls-row" id="when" style="margin-top:5px;">
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
<button type="submit" class="btn btn-primary" id="submitButton">Save</button>
</div>
</div>
</div>
</div>
<div id="calendarModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Event Details</h4>
</div>
<div id="modalBody" class="modal-body">
<h4 id="modalTitle" class="modal-title"></h4>
<div id="modalWhen" style="margin-top:5px;"></div>
</div>
<input type="hidden" id="eventID"/>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
<button type="submit" class="btn btn-danger" id="deleteButton">Delete</button>
</div>
</div>
</div>
</div>
<!--Modal-->
<div style='margin-left: auto;margin-right: auto;text-align: center;'>
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-21769945-4', 'auto');
ga('send', 'pageview');
</script>
<div>
<h1> La fin ya scampo </h1>
</div>
</div>
index.php
...
...
<div class="tab-pane fade" id="Agenda">
<?php include("agenda.php"); ?>
</div>
...
...
i expect the code to show a calendar in a part of my index.php.
PS: when i delete the modal class from the div tag it works all fine, i know that the modal should be in the top, but aren't there any other method?

The PHP include file is not the problem. There is no reason why you cannot have the Bootstrap modal in a PHP include file. The include file is injected into the HTML code before the DOM is rendered, so there should be no problem.
HOWEVER... Possibly, the problem is having the Bootstrap modal dialog structure be added to the HTML inside another div -
<div class="tab-pane fade" id="Agenda">
<?php include("agenda.php"); ?>
</div>
The Bootstrap modal should be at the first level under the body tag. That is where Bootstrap expects it to be. Doing that should not be a problem, since the Bootstrap modal is invisible until displayed... Resist the temptation to add additional layers of HTML outer containers to the Bootstrap divs until you are really sure you understand Bootstrap scaffolding.
Also, having the fade tag on that same #Agenda div (the one that the modal dialog is in) might not be a good idea. Note that you do not need the modal inside the #Agenda div in order to use it for an agenda (calendar?) functionality.
I suggest that until you solve your problem, get rid of all the include files. Take the code in your PHP include files and stick it into the main body, so that you only have the one index.php file, with no includes. Once you get it working, you can then break things out into the include files. Simplify to solve.

Related

modal is not opening and not showing any error (all divs are closed)

Edited to include proper format for more readable and understandable code. Also fixed to where the proper placement for ideal performance with the Javascript files are added to the ending of the <html> tag opposed to the <head> tag
<!DOCTYPE html>
<html>
<head>
<title>ROWLANDS SHOP</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<meta name="viewport" content="width=device-width, initial-scale=1, user-
scalable=no">
</head>
<body>
<div class="modal fade details-1" id="details-modal" tabindex="-1"
role="dialog" aria-labelledby="details-1" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button class="close" type="button" onclick="closeModal()"
aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" class="text-center"><?=
$product['title'];?></h4>
</div>
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col-sm-6">
<div class="center-block"></div>
<img src="<?= $product['image'];?>" alt="<?
=$product['title'];?>" class="details img-responsive">
</div>
<div class="col-sm-6">
<h4>Details</h4>
<p><?= $product['description'];?></p>
<hr>
<p>price: $<?= $product['price'];?></p>
<p>Brand:<?= $brand['brand']; ?></p>
<form action="add_cart.php" method="post">
<div class="form-group">
<div class="col-xs-3">
<label for="quantity">Quaantity:</label>
<input type="text" class="form-control" id="quantity"
name="quantity">
</div>
</div>
<div class="form-group">
<label for="size">Size:</label>
<select name="size" id="size" class="form-control">
</select>
<option vaue=""></option>
<?php foreach($size_array as $string){
$string_array = explode(':', $string);
$size = $string_array[0];
$quantity = $string_array[1];
echo '<option
vaue="'.$size.'">'.$size.'('.$quantity' Avaliable)</option>';
} ?>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-default"
onclick="close_modal();">Close</button>
<button class="btn btn-warning" type="submit"
class="glyphicon glyphicon-shopping-cart"><span>Add to Cart</span></button>
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
</html>
Is other styles from Bootstrap Working? And could you please give more information such as where you are including the Javascript and Popper.js? I'm sorry but there is so much little information that is given that it could simply just be it's not loading Bootstrap into the project. Please revise and add some more information that can possibly help us debug this for you.
Here is the boilerplate for a modal in bootstrap and a trigger with a button. Take this and see if this works for you and then you can re-add the other components you had to it. If this doesn't open up a modal then it might just be a loading problem with Bootstrap.js.
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Here is the link to the official Bootstrap Documentation. https://getbootstrap.com/docs/4.4/components/modal/
Also Please note that the code you have provided is missing the required Popper.js file. Please Add this code above the ending <html> tag.
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
If you simply don't want to use the online versions of the Bootstrap.js, Jquery.js, or Popper.js Here are the websites where you can find them and download them to easily extract to your project.
Jquery Code Uncompressed: https://code.jquery.com/jquery-3.4.1.js - Just save this into a file called jquery.js and include it with a script tag
Bootstrap.js: Can be downloaded from the official Bootstrap Website - https://www.getbootstrap.com
Popper.js: https://popper.js.org/ - Can be downloaded here
Also please read the StackOverflow Guide to asking a good question you can find here at: https://stackoverflow.com/help/how-to-ask

Why is the echoing of my html file in wordpress sidebar widget breaking other widget front-side widget styling?

My use case for the WordPress plugin is quite simple. I want to provide a plugin that sets up a custom sidebar widget that a user can activate then place where ever they please (or where ever the sidebar widgets areas allow them).
The plugin provides a search functionality that does a bunch of stuff. The "search" functionality is built completely in HTML/JS.
I have gone through creating a WordPress plugin boilerplate using Alessandro Castellani youtube series called "Wordpress Plugins Development Tutorials".
My folder structure more or less looks like the tutorial code that goes with the series (at least the more widget specify files). Found Here
Despite the complexity of the structure used in the tutorial and the simplistic nature of my particular use case, I like the extensibility/scalability the plugin architecture used provides. I digress.
I've created and called the proper WP_Widget class methods; widget, form, and update.
The plugin successfully instantiated the custom sidebar widget on the admin side and is able "drag and drop" as I please.
For the rendering of the front-side content, I am using file_get_contents() to retrieve the contents of the HTML file inside the widget() method. Then I echo out the contents BEFORE the $args['after_widget'] declaration.
This is the code snippet of the widget method code.
public function widget( $args, $instance ) {
$searchHTML = file_get_contents(PLUGIN_URL . '/api-search.html', __FILE__);
echo $args['before_widget'];
if ( ! empty( $instance['title'] ) ) {
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
}
//$searchHTML = file_get_contents(plugins_url('api-search.html', __FILE__));
//echo $searchHTML;
echo $args['after_widget'];
}
When I check the front side, the HTML "search" functionality loads properly, as well as the adjoining JS files enqueued. It works as intended.
The issue is despite the widget loading the files like I want it to, it seems to break the other widgets.
This is how it looks like before echoing the HTML content.
This is how it looks like after echoing the HTML content.
If there are portions of my code I should provide to troubleshoot this, let me know and I will happily do so. At the moment, can't think of any other methods used would be the issue.
EDIT: Portions of my SO edits are not saving!
EDIT: Adding the entire code of "api-search.html". I should mention that this code is strickly prototype and has not been cleaned up... obviously lol.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>MBE AUTOCOMPLETE</title>
<script
src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"
></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"
></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link
rel="stylesheet"
href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"
/>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"
/>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"
></script>
<link
rel="stylesheet"
href="https://unpkg.com/purecss#1.0.0/build/pure-min.css"
integrity="sha384-nn4HPE8lTHyVtfCBi5yW9d20FjT8BJwUXyWZT9InLYax14RDjBj46LmSztkmNP9w"
crossorigin="anonymous"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<link rel="stylesheet" type="text/css" href="assets/css/mbe-style.css" />
<script src="https://unpkg.com/ionicons#4.5.0/dist/ionicons.js"></script>
<script
type="text/javascript"
src="/assets/scripts/mbe-api-functions.js"
></script>
<style>
#import url('https://fonts.googleapis.com/css?family=Thasadith');
</style>
<script type="text/javascript"> function hideSelectSubModal() {
$("#selectSubcategory").modal("hide");
}
//$("#modal").on("load", createRadioButtonFromArray(subList));
function getCategory() {
let output = autocomplete();
$(function() {
$("#industry").autocomplete({
source: output
});
});
$("#industry").on("autocompleteselect", function(event, ui) {
getSubList();
});
}
function getSubList() {
$("#industry").autocomplete({
select: populateModal()
});
}</script>
</head>
<body class="mbe-plugin">
<div class="ui-widget">
<form role="form">
<label for="industry">Search For Professional: </label>
<input
type="text"
name="param"
id="industry"
oninput="getCategory()"
size="30"
/>
<td colspan="2" align="center">
<button
type="button"
class="btn btn-primary"
data-toggle="modal"
data-target="#selectSubcategory"
onclick="populateModal()"
>
Find
</button>
<!-- <input type="submit" value="Submit" /> -->
</td>
</form>
</div>
<!-- First Modal: selectSubcategory -->
<div
class="modal fade"
id="selectSubcategory"
tabindex="-1"
role="dialog"
aria-labelledby="selectSubcategoryLabel"
aria-hidden="true"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="selectSubcategoryLabel"></h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="select_subcategory" onclick="getCheckBox()"></form>
<!--
<input class="form-control" type="radio" id="subcategory_list"> </select>
-->
</div>
</div>
</div>
</div>
<!-- Inbetween -->
<div
class="modal fade"
id="inBetween"
tabindex="-1"
role="dialog"
aria-labelledby="inBetweenLabel"
aria-hidden="true"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="inBetweenLabel">Just a few question:</h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p> This is to better connect you with a proffesional, we will not sell your information.<p>
<button type="button" class="btn btn-primary" onclick="initQuestionDisplay()">Save changes</button>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
<!-- Form submission modal -->
<div
class="modal fade"
id="formSubmit"
tabindex="-1"
role="dialog"
aria-labelledby="formSubmitLabel"
aria-hidden="true"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="formSubmitLabel">
Enter your information
</h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form class="gform pure-form pure-form-stacked" method="post" data-email="mbetestemail#gmail.com" action="https://script.google.com/macros/s/AKfycbyBzmpwpTU9vPWVDE_p8KQI-_ZjWTdlJOJ-FZ41/exec">
<form class="gform pure-form pure-form-stacked" method="post" data-email="mbetestemail#gmail.com" action="CALL TO GOOGLE SCRIPT FILE">
<div class="form-elements">
<div class=" pure-g">
<!-- <fieldset class="pure-group"> -->
<fieldset class="pure-u-1-2 pure-u-md-1-3">
<label for="name">Name: </label>
<input id="name" class="pure-u-23-24" name="name" placeholder="Full name!" />
</fieldset>
<!-- <fieldset class="pure-group"> -->
<fieldset class="pure-u-1-2 pure-u-md-1-3">
<label for="email">Email:</label>
<input id="email" class="pure-u-23-24" name="email" type="email" value=""
required placeholder="your.name#email.com"/>
<span class="email-invalid" style="display:none">
Must be a valid email address</span>
</fieldset>
<fieldset class="pure-u-1 pure-u-md-1-3">
<label for="name">Phone Number: </label>
<input id="phone_number" class="pure-u-23-24" name="phone_number" placeholder="Name of your company or company you work for" />
</fieldset>
<fieldset id="form-answer-box" class="pure-u-1 pure-u-md-1-3">
<label for="answers"></label>
<!-- Shouldnt be input, insert data into a tag tag dynamically? with inner or cosument.write then hide -->
<input id="answer-field" class="pure-u-23-24" name="answer-field" placeholder="Name of your company or company you work for" />
</fieldset>
</div>
<button class="button-success pure-button button-xlarge" onclick="initResultDisplay()">
<i class="fa fa-paper-plane"></i> Submit</button>
</div>
<div class="thankyou_message" style="display:none;">
<h2><em>Thanks</em> for contacting us!
We will get back to you soon!</h2>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Questions modal -->
<div
class="modal fade"
id="questionsDisplay"
tabindex="-1"
role="dialog"
aria-labelledby="questionsDisplayLabel"
aria-hidden="true"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="questionsDisplayLabel">
QUESTIONS
</h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div
class="modal-body"
data-bind="template: {name: 'template', data: $data}"
></div>
<script type="text/html" id="template">
<div class="diplay-frame" data-bind="foreach: {data: data, as: '_data'}">
<div class="question-box">
<h2 class="question" id="ques" data-bind="text: _data['question']"/>
<div data-bind="foreach: {data: _data['answers'], as: 'answer'}">
<input type="radio" id="ans" data-bind="checked: $parent.selectedAnswer, attr:{name: $parent.optionGroupName, value: $data}" />
<span data-bind="text: answer"/>
</div>
</div>
</div>
</script>
<button
type="button"
onclick="captureAnswers()"
class="btn btn-secondary"
data-dismiss="modal"
>
Next
</button>
</div>
</div>
</div>
<!-- Search result Display Modal -->
<div
class="modal fade"
id="searchResultDisplay"
tabindex="-1"
role="dialog"
aria-labelledby="searchResultDisplayLabel"
aria-hidden="true"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="searchResultDisplayLabel">
Search Results
</h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div
class="modal-body"
data-bind="template: {name: 'template1', data: $data}"
></div>
<script type="text/html" id="template1">
<div class="diplay-frame" data-bind="foreach: {data: data, as: '_data'}">
<div class="result-box">
<div class="bgtint"></div>
<section class="businesscard">
<div class="flip">
<div class="front">
<div class="logo">
<img class="profile_image" width="50px" height="50px" data-bind="attr:{src: _data['profile_image']}"/>
<a data-bind="attr:{href: _data['profile_link'], target: '_blank'}"><h2 class="user_name" data-bind="text: _data['username']"/></a>
<div class="introduction"><h4 class="company_name" data-bind="text: _data['business_name']"/></div>
<div class="arrow"></div>
</div>
</div>
<div class="userinfo">
<div class="col-sm-4" id="phone-box">
<ion-icon name="call"></ion-icon>
<p class="user_mobile" data-bind="text: _data['mobile']"/>
</div>
<div class="col-sm-4" id="email-box">
<ion-icon name="mail"></ion-icon>
<p class="user_email" data-bind="text: _data['email']"/>
</div>
</div>
</section>
</div>
</div>
</script>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
<script data-cfasync="false" type="text/javascript" src="assets/scripts/form-submission-handler.js"></script>
</body>
</html>

How to set the modal shows something based on a button click?

I really want that my Modal shows something based on which button inside it i press, but i have no idea of how to do this.
Actually i tried to use if(isset($_POST['buttoname'])
but looks like this dowsn't work `
This is my modal , i just want to place the content on the right side (which is white ) , but actually it doesn't work.
Here's the code i tried to use
<!-- Modal Settings -->
<div class="modal fade" id="Settings" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" style="background-color: #d9534f;color:white !important;text-align: center;font-size: 30px">
<button type="button" class="close" data-dismiss="modal" style="background-color: #d9534f;color:white !important;text-align: center;font-size: 30px">×</button>
<h4 style="background-color: #d9534f;color:white !important;text-align: center;font-size: 30px"><span class="fa fa-gear"></span> Settings</h4>
</div>
<div class="modal-body">
<div class="container">
<div class="list-group col-sm-1">
<form method="post" href="#">
<button type="submit" name="Profile" href="#" class="list-group-item">First </button>
<button type="submit" name="Logins" href="#" class="list-group-item">First </button>
<button type="submit" name="Security" href="#" class="list-group-item">First </button>
</form>
</div> <!-- List -->
</div>
<?php
if(isset($_POST['Profile'])){
echo' <div class="container">
<div class="col-sm-11">
<p> This is a test</p>
</div>
</div>';
}
?>
</div>
<div class="modal-footer" style="background-color: #f9f9f9;">
<button type="submit" class="btn btn-danger btn-default pull-left" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
</div>
</div>
</div>
</div>
<!-- Modal Settings -->
You need to actually post the button click to have it stored in the $_POST. So just leave the form action empty and it will post this form to the url you already are in.
But this will refresh the page so if you want to make it without refreshing you will need to use javascript.
For example if you are using jquery and you are if you are using bootstrap
In you html put some placeholder div instead of this php if:
</div> <!-- List -->
</div>
<div id="placeholder"></div>
</div>
And in your javascript code:
$("button[name='Profile']").click(function() {
$("#placeholder").html("YOUR HTML CODE");
});

Bootstrap Modal Works On Mobile Device Only

Hello,
I created a bootstrap 3 modal and it works on my mobile device but on my desktop when you click the button it does not open the modal.
I've tried resizing the modal box even adjusting it's zindex but those did not fix the problem.
Does anyone know what the issue is i'm having?
<div class="container-fluid formbox ">
<div id="cageModal" class="modal fade" role="dialog" class="col-sm-10 col-sm-offset-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Cage The Great</h4>
</div>
<div class="modal-body">
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/VqghSmwdnpg" frameborder="no" allowfullscreen></iframe>
<button type="button" class="btn btn-default" data-dismiss="modal">See More</button>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid formbox ">
<div class="col-xs-12 col-sm-12">
<h3>Get Familiar with the artists below.</h3>
<div class="col-xs-8 col-xs-offset-2 col-sm-6 col-sm-offset-3">
<div> <button type="button" class="btn btn-block btn-info btn-lg" data-toggle="modal" data-target="#cageModal">Cage The Great</button>
</div>
</div>
</div>
</div>
Non-working code on jfiddle
Your code is correct. But your bootstrap references (CDN) are not.
replace your references to Bootstrap with the latest. Or better yet, use Bootstrap locally and never touch it!
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
Here is your broken jfiddle, now working

bootstrap issue, "fileupload" not working inside of a modal

So, i am using a bootstrap modal, and inside of the modal, i want to use image upload, but when an image is selected, nothing happens, i am asuming it is a javascript issue, the script and the css is included outside of the modal in the header.
http://jasny.github.com/bootstrap/javascript.html#fileupload
Any suggestions? I asume it is a javascript issue
<?php
if (isset($_SESSION['login']) and !empty($_SESSION['login']) and $_SESSION['rank'] == 3) {
echo '
<!-- Modal -->
<div id="insert_post_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Insert Post</h3>
</div>
<div class="modal-body">
<p>
<form action="insert_post_sql" method="post" enctype="multipart/form-data">
<table border="0">
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="fileupload-new thumbnail" style="width: 200px; height: 150px;"><img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&text=no+image" />
</div>
<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 200px; max-height: 150px; line-height: 20px;">
</div>
<div>
<span class="btn btn-file"><span class="fileupload-new">Select image</span>
<span class="fileupload-exists">Change</span><input type="file" /></span>
Remove
</div>
</div>
</table>
</form>
</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<input type="submit" button class="btn btn-primary" value="Submit Post">
</div>
</div>
</form>
';
}
?>
Try to use Document Ready function because the Script is loaded prior to the Modal HTML
$('document').ready(function(){
$('#insert_post_modal').on('shown', function(){
$('.fileupload').fileupload();
});
});
Try calling the fileupload on modal shown (i.e. when the user opens it):
$('#insert_post_modal').on('shown', function(){
$('.fileupload').fileupload();
});
Can't test it right now though, I'm sorry
$(document).ready(function(){
$image_crop = $('#image_demo').croppie({
enableExif: true,
viewport: {
width:300,
height:300,
type:'square' //circle
},
boundary:{
width:400,
height:400
}
});

Categories