React unit testing, enzyme/mocha testing (or mocking?) html image api
Date : March 29 2020, 07:55 AM
may help you . The Image() constructor is part of the browser and therefore not in Node.js. When you call new Image() in the browser it is equivalent to call new window.Image(). With jsdom you have set global.window to emulate the browser's window. That means you now have access to window.Image. If you want to make it available without the window prefix you can make it global, there is no need to make a spy or a mock manually. Simply add this to your test setup: global.Image = window.Image;
|
code working in jfiddle but not in jfiddle result
Date : March 29 2020, 07:55 AM
wish help you to fix your issue This is an addition to @zhuravlyoy's answer, since his answer won't make the new row blank if the previous one was edited. $( document ).ready(function() {
$('#tableone').on('click', '.editbtn', function() {
var $this = $(this);
var tds = $this.closest('tr').find('td').filter(function() {
return $(this).find('.editbtn').length === 0;
});
if ($this.html() === 'Edit') {
$this.html('Save');
tds.prop('contenteditable', true);
} else {
$this.html('Edit');
tds.prop('contenteditable', false);
}
});
$('.addnewrow').click(function() {
var $tr = $("#tableone").find("tr:last");
var $clone = $tr.clone();
$clone.children('.td').empty();
$clone.children('.td').attr('contenteditable', false);
$clone.find('.editbtn').text('Edit');
$tr.after($clone);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="tableone" border="2" cellspacing="2" cellpadding="2">
<thead>
<tr>
<th class="col1">Seminar Name</th>
<th class="col2">Seminar Date</th>
<th class="col3">Download Link</th>
<tbody>
<tr class="del">
<td contenteditable="false" class="td"></td>
<td contenteditable="false" class="td"></td>
<td contenteditable="false" class="td"></td>
<td>
<button class="editbtn">Edit</button>
</td>
</tr>
<tr class="del" id="tablerow">
<td contenteditable="false" class="td"></td>
<td contenteditable="false" class="td"></td>
<td contenteditable="false" class="td"></td>
<td>
<button class="editbtn">Edit</button>
</td>
</tr>
</tbody>
<button class="addnewrow">Add New Row</button>
|
Date : March 29 2020, 07:55 AM
hop of those help? Is this what you are trying to achieve? Its working fine on my localhost, I put it all in one file index.php. Make sure the way you call your css and js files are correct, also try to force refresh your browser ctrl f5. And this is should be obvious but just to be sure, make sure you are connected to internet. And take note Im using sublime text because its more easy to use for me than brackets. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<title>Responsive menu</title>
<div class="container">
<nav>
<a class="burger-nav"></a>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</div>
<script type="text/javascript">
$(document).ready(function(){
$(".burger-nav").on("click", function(){
$("nav ul").toggleClass("open");
});
});
</script>
<style type="text/css">
header {
background: white;
padding-bottom: 20px;
}
nav {
float: right;
padding-right: 10%
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 35px;
padding-top: 25px;
position: relative;
}
nav a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 24px;
}
nav a:hover {
color: #000;
}
nav a::before {
content: '';
display: block;
height: 10px;
width: 0%;
background-color: #444;
position: absolute;
top: 0;
transition: all ease-in-out 150ms;
}
nav a:hover::before {
width: 100%;
}
@media only screen and (max-width:480px) {
.burger-nav{
display: block;
height: 40px;
width: 40px;
float: right;
background: url("https://cdn4.iconfinder.com/data/icons/wirecons-free-vector-icons/32/menu-alt-512.png");
background-size: cover;
cursor: pointer;
}
.wrapper {
width: 100%;
padding: 0;
}
nav ul {
overflow: hidden;
background: white;
height:0;
}
nav ul.open {
height: auto;
}
nav ul li{
float:none;
text-align: left;
width: 100%;
margin: 0;
}
nav ul li a {
color: black;
padding: 10px;
display: block;
margin: 0;
}
}
@media only screen and (max-width:1050px) {
.burger-nav{
display: block;
height: 40px;
width: 40px;
float: right;
background: url("https://cdn4.iconfinder.com/data/icons/wirecons-free-vector-icons/32/menu-alt-512.png");
background-size: cover;
cursor: pointer;
}
.wrapper {
width: 100%;
padding: 0;
}
nav ul {
overflow: hidden;
background: white;
height:0;
}
nav ul.open {
height: auto;
}
nav ul li{
float:none;
text-align: left;
width: 100%;
margin: 0;
}
nav ul li a {
color: black;
padding: 10px;
display: block;
margin: 0;
}
}
</style>
|
Javascript works in JFIDDLE but not HTML file
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Why wont this code work? It seems to only work on JFIDDLE.. Is there permissions or something? , Like this: <html>
<body>
<button type="button" onclick="loadData()">Load Spreadsheet Data</button>
<div id="display"></div>
<script>
function loadData() {
var url="https://docs.google.com/spreadsheet/pub?key=p_aHW5nOrj0VO2ZHTRRtqTQ&single=true&gid=0&range=A1&output=csv";
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status==200){
document.getElementById("display").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
</script>
</body>
</html>
|
Why is jQuery script working on jFiddle, but not working on my local machine?
Date : March 29 2020, 07:55 AM
|