Can't use emojionearea in django - javascript

I can't use emojionearea in a simple page in Django. I have followed the basics steps, listed on their website:
What I have done:
downloaded the zip from their GitHub and copied both of these files into CSS and JavaScript folder
configure django static settings e.g add to url, add static dir, add url pattern
added the script written above.
Code:
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TODO</title>
<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="{% static 'css/emojionearea.min.css' %}">
<link rel="stylesheet" href="{% static 'css/main.css' %}">
</head>
<body>
{% include 'navbar.html' %}
{% block content %}
{% endblock content %}
<script>
$(document).ready(function() {
$("#mytextarea").emojioneArea();
})
</script>
<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://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="{% static 'js/emojionearea.min.js' %}"></script>
</body>
</html>
and this is the form text area I want to add the emoji to:
<form method="post" action="" class="edit">
{% csrf_token %}
<div class="form-row">
<div class="col-12">
<label for="inputTask">Tweet:</label>
<textarea class="form-control" placeholder="Enter Tweet:" name="tweet" id="mytextarea"></textarea>
</div>
<div class="col-10">
<label for="inputTime">Image:</label>
<input type="file" class="form-control" placeholder="select image:" name="images">
</div>
<div class="col-2" style="margin-top: 35px;">
<button type="submit" class="btn btn-outline-primary float-right">Add Tweet</button>
</div>
</div>
</form>
I have also tried putting textarea out of form tag and do the stuff on it, but still no effect

Related

jQuery Datatables error (Uncaught TypeError: $ is not a function)

Im trying to get datatables to work for a basic table
This is my error
Below is my layouts file, where i include the script tags and css tags / they are noted
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<!-- font awesome icon kit - check favourite tabs in chrome to get more -->
<script src="https://kit.fontawesome.com/69e69f8319.js" crossorigin="anonymous"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{config('app.name', 'Coffee')}}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<link rel="stylesheet" href="../css/app.css">
<!-- ck editor cdn-->
<script src="https://cdn.ckeditor.com/4.15.1/standard/ckeditor.js"></script>
<!-- Datatables link -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.23/css/dataTables.bootstrap4.min.css">
</head>
<body style="background-color: lightgrey !important;">
#include('inc.admin_navbar')
<div class="container">
#yield('content')
#if(session('success_message'))
<div class="alert alert-success">
{{session('success_message')}}
</div>
#endif
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
<!-- datatables js link -->
<script src="https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.23/js/dataTables.bootstrap4.min.js"></script>
#include('sweetalert::alert')
</body>
</html>
Here is my file that includes the targeted table and the javascript. This file extends from the layouts file where the datatable links are nested
<table id="datatable" class="table table-striped table-hover">
<htead>
<th>ID</th>
<th>Name</th>
<th>Date Joined</th>
<th></th>
</htead>
<tbody>
#foreach($posts as $post)
<tr>
<th>{{$post->id}}</th>
<th>{{$post->title}}</th>
<th>{{$post->created_at}}</th>
<th>
<div class="row">
<div class="col">
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#editModal">Edit</button>
</div>
<div class="col">
<button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#delete">Delete</button>
</div>
</div>
</th>
</tr>
#endforeach
</tbody>
</table>
Here is the js at the bottom on the file
<script type="text/javascript">
$(document).ready(function () {
//linked to our main table - js function
var table = $('#datatable').DataTable();
})
</script>
please include Jquery before datatable load
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
Include jQuery into your code, right after body tag ends </body>
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>

Add input value to Alert Dialog Boxes

How i can put the value from input type id "email" to my alert box?
The rest code its working in my opinion,i just cant make the alert box displaying the value from my e-mail form.
Using bootstrap just too make some cool design.
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<div class="container">
<div class="box">
<form class="text-center border border-light p-5">
<p class="h4 mb-4">CHANGE E-MAIL</p>
<p>Input Old E-mail and New E-mal</p>
<!-- Name -->
<input type="email" id="email1" class="form-control mb-4" placeholder="E-mail">
<!-- Email -->
<input type="email" name="email" id="email" class="form-control mb-4" placeholder="E-mail">
<!-- Sign in button -->
<button class="btn btn-dark btn-block" id="tombol_form" type="submit" onclick = "check();">SUBMIT</button>
</form>
</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<script type="text/javascript">
var email=document.getElementById("email").value;
function check() {
alert ("Success your email change to: " +email)
}
</script>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
You just need to get the input value inside your check function, since otherwise it's got when you website loads, not when you click the button.
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<div class="container">
<div class="box">
<form class="text-center border border-light p-5">
<p class="h4 mb-4">CHANGE E-MAIL</p>
<p>Input Old E-mail and New E-mal</p>
<!-- Name -->
<input type="email" id="email1" class="form-control mb-4" placeholder="E-mail">
<!-- Email -->
<input type="email" name="email" id="email" class="form-control mb-4" placeholder="E-mail">
<!-- Sign in button -->
<button class="btn btn-dark btn-block" id="tombol_form" type="submit" onclick = "check();">SUBMIT</button>
</form>
</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<script type="text/javascript">
function check() {
var email=document.getElementById("email").value; //Moved this into the 'check'-function
alert ("Success your email change to: " +email)
}
</script>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
I would like to suggest using the [HTML <dialogue> Element] (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog). Easy to setup and works like a charm!

ReferenceError: toastr is not defined when using Material Bootstrap alert

I'm trying to use Material Bootstrap Alert in my Django app. If user inputs wrong password or username while trying to login to the page, the error toast message should appear in the upper right corner. With js alert it works perfectly fine but when I'm trying to invoke toastr.error('Wrong login credentials. Please, try again...'); I get these erorrs:
jQuery.Deferred exception: toastr is not defined #http://127.0.0.1:8000/login/:63:9
j#http://127.0.0.1:8000/static/js/jquery-3.2.1.min.js:2:29997
g/http://127.0.0.1:8000/static/js/jquery-3.2.1.min.js:2:30313
undefined
ReferenceError: toastr is not defined
Here is my login.html page:
{% extends 'utas/template.html' %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{% block title %}Login{% endblock %}</title>
</head>
<body>
{% block pagecontent %}
<div class="container">
<!-- Begin Form login -->
<form method="post" class="mt-5" style="width: 24rem; margin: 0 auto;">
{% csrf_token %}
<p class="h5 text-center mb-4">Sign in</p>
<div class="md-form">
<i class="fa prefix material-icons grey-text">account_circle</i>
<input type="text" id="defaultForm-user" class="form-control" name="username"
required
oninvalid="this.setCustomValidity('Username is required!')"
oninput="setCustomValidity('')">
<label for="defaultForm-user">Your username</label>
</div>
<div class="md-form">
<i class="fa prefix material-icons grey-text">lock</i>
<input type="password" id="defaultForm-pass" class="form-control" name="password"
required
oninvalid="this.setCustomValidity('Password is required!')"
oninput="setCustomValidity('')">
<label for="defaultForm-pass">Your password</label>
</div>
<div class="text-center">
<button type="submit" class="btn btn-default">Login</button>
</div>
</form>
<!-- End Form login -->
</div>
{% endblock %}
{% block script %}
{% if form.errors %}
<script type='text/javascript'>
$(document).ready(function()
{
toastr.error('Wrong login credentials. Please, try again...');
});
</script>
{%endif%}
{% endblock %}
</body>
</html>
And here is my template.html with required scripts:
{% load static %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>UTAS - {% block title %}{% endblock %} </title>
<!-- Material Icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<!-- Material Design Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.4.1/css/mdb.min.css" rel="stylesheet">
<!-- Custom styles -->
<link href="{% static 'css/style.css'%}" rel="stylesheet">
</head>
<body>
{% block pagecontent %}
{% endblock %}
</body>
<script src="{% static 'js/jquery-3.2.1.min.js'%}"></script>
<script src="{% static 'js/popper.min.js'%}"></script>
<script src="{% static 'js/bootstrap.min.js'%}"></script>
<script src="{% static 'js/mdb.min.js'%}"></script>
{% block script %}
{% endblock %}
</html>
I'm not very experienced with JS or jQuery. All javascript files are from official MDB website.
Found the reason of error. I've been using version of framework which don't have toast messages

Dropzone.js not working with Google Chrome

I'm using dropzone in conjunction with Bootstrap and Django, the dropzone actually appears in Safari and Firefox, but does not show up correctly in Chrome. I'm using Chrome version 45.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Metadata</title>
{% load staticfiles %}
<link href="{% static 'main/css/bootstrap.css' %}" type="text/css" rel="stylesheet"/>
<link href="{% static 'main/css/dropzone.css' %}" type="text/css" rel="stylesheet"/>
</head>
<body>
<div class="container">
<!-- Main component -->
<div>
<form action="/file-upload" class="dropzone" id="myDropzone">
<!--<button id="submit-all"> Submit all files </button> -->
</form>
</div>
</div> <!-- /container -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="{% static 'main/js/bootstrap.min.js' %}"></script>
<!-- DROPZONE -->
<script src="{% static 'main/js/dropzone.js' %}"></script>
</body>

AngularJs Ui route not working?

Hi I was advised to use ui-router due to having problems with nested views.
I'm trying to create a form like this to go in the middle of my page.
the form
However it doesn't work and it's made my website not being able to load properly. I cannot view anything from the header down. The logo and the header works...but No body and no footer. Form pages are in partials/form.html etc. The body and footer loaded fine before I edited the code to include the forms.
Here's my plunker my app
here's index.html
<html ng-app="financeApp">
<head>
<meta charset="utf-8">
<!-- CSS -->
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.0.0/css/font-awesome.css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<header>
<div class="wrap">
<!-- logo -->
<img class="logo" src="img/logo.png" />
</div>
<body ng-controller = "demoCtrl">
<ul class="nav nav-pills pull-right">
<li ng-class="{active: isState('home') }">
<a ui-sref="home">Home</a>
</li>
<li ng-class="{active: isState('form') }">
<a ui-sref="form">Form</a>
</li>
<li ng-class="{active: isState('contact') }">
<a ui-sref="contact">Contact</a>
</li>
</ul>
<h3 class="text-muted">Demo Page</h3>
<br>
<div ui-view=""></div>
</div>
<!-- Loading the Footer -->
<div id="footer" ng-include="'partials/footer.html'"></div>
<!-- App JS -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.min.js"></script>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-route.min.js"> </script>-->
<!-- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-animate.js"> </script>-->
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.10/angular-ui-router.min.js"> </script>
<script src="js/script.js"></script>
<!--<script src="//cdn.jsdelivr.net/jquery.slick/1.3.15/slick.min.js"></script>-->
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.6.0.js"> </script>
<script src="https://code.jquery.com/jquery-git2.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="js/controllers/controllers.js"></script>
<script src="js/directives/directives.js"></script>
<link data-require="bootstrap-css#3.1.1" data-semver="3.1.1" rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<script data-require="angular.js#*" data-semver="1.3.0-beta.5" src="https://code.angularjs.org/1.3.0-beta.5/angular.js"></script>
<script data-require="bootstrap#*" data-semver="3.1.1" src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
</body>
</html>
Thanks

Categories

Resources