Console.log does nothing in console on Firefox - console.log

I found several threads about console.log not working on certain browsers couple years ago, I guess the issue should be solved today. Yet the following code doesn't display anything in Firebug's "console" tab (FF 43.04):
if (window.console) console.log( 'changed' );
Any idea why?
EDIT: no output, no error. This code was added inside .on( 'change', 'input:radio', function() { }); which fires when $( 'input[value="whatever"]' ).change(); runs.

You may try creating a file like a.html and placing it in your local IIS at c:\inetpub\wwwroot with contents:
<script>
if (window.console) console.log( 'changed' );
</script>
Then open debugger tools with CTRL+SHIFT+I, select console tab and then JS table. Open url http://localhost/a.html and it should work.
Firefox with console

Related

Highcharts on zeppelin 0.6.0 executes but does not display any chart

I am using zeppelin 0.6.0 (zeppelin-0.6.0-incubating-SNAPSHOT from Hortonworks) and wanted to try out highcharts. So I followed the link to setup my zeppelin. However the zeppelin UI did not have option to add the dependency. So, I made change to the zeppelin configuration file and added the following after copying the jar files - spark-highcharts-0.6.0.jar,
lift-json_2.10-2.6.3.jar and paranamer-2.4.1.jar.
export ZEPPELIN_JAVA_OPTS="-Dspark.executor.memory=8g -Dspark.cores.max=16 --packages com.knockdata:zeppelin-highcharts-0.6.0"
I ran the tutorial notebook in zeppelin and loaded the data.
As per the instructions, I executed java script which ran without any error.
%angular
<script type="text/javascript">
$(function () {
if (typeof Highcharts == "undefined") {
$.getScript("http://code.highcharts.com/highcharts.js")
.done(function( script, textStatus ) {
console.log( "load http://code.highcharts.com/highcharts.js " + textStatus );
})
.fail(function(jqxhr, settings, exception ) {
console.log("load http://code.highcharts.com/highcharts.js " + exception);
});
} else {
console.log("highcharts already loaded");
}
});
</script>
Then I ran the following to plot data which ran fine but there was nothing to plot. Also checked browser console and it did not show any error. Interestingly the java script which i ran earlier did not show any message in browser console too (Expected "highcharts already loaded" message in the console).
%spark
import com.knockdata.zeppelin.highcharts._
import com.knockdata.zeppelin.highcharts.model._
highcharts(bank.series("x" -> "age", "y" -> avg(col("balance")))
.orderBy(col("age"))).plot()
Please let me know what is missing here.
Thanks
This might sound weird but it looks like an issue with Chrome. While experimenting, I started chrome in Incognito mode and ran the highcharts again. This time it showed the chart. Later I cleared the history in Chrome and ran in regular mode.I was able to see the plot. Hope this helps somebody.

jsPDF downloading blank pdf

I'm using jsPDF to generate a pdf from the current HTML, the code works fine if I paste it on the console and downloads a PDF with the current HTML, but when I put it on a JS file it downloads a blank PDF:
This is the code:
<script>
function descargar_pdf(){
var pdf = new jsPDF();
pdf.addHTML(document.body,function() {});
pdf.save('Estadodecuenta.pdf');
};
</script>
The function is called from a button:
<button class="descargar_pdf" id="ignorePDF" onclick="descargar_pdf();"> Descarga tu estado de cuenta</button>
The second argument in the addHTML function is a callback function which gets called after the HTML is rendered.
pdf.addHTML(document.body, function() {
pdf.save('*.pdf');
});
The last correctly working version of html2canvas is RC1. Downgrade to that one and it should work as expected.
This may sound stupid but there's a lot of security plugins that see JSPDF as an "unsafe" js and just block it , i had the same problem as you did but after testing it out on incognito mode (no extensions) it worked fine.
This may not the solution to your problem but its a advice you should keep in mind

jquery-ui button selection with firefox and internet explorer

Hey the following code works with chrome,safari and opera without problem. But it does work neither with firefox nor internet explorer.
Thanks for help!!!
$("#myButton" ).button(
{icons: {primary: "ui-icon-circle-plus",secondary: "ui-icon-triangle-1-s"}});
$( "#myButton .ui-icon-circle-plus").click(
function(){alert("myButton");})
You can find the example in the following link:http://jsfiddle.net/asiaminor/suw0xs89/
That's because the browser hasn't yet finished rendering your jQueryUI styles, and your selector can't match anything in the DOM. Use Event delegation:
$( "#myButton" ).click( ".ui-icon-circle-plus", function(){alert("myButton");})
Fiddle here

Why isn't jquery working in Rails 3.1?

If I go to http://localhost:3000/assets/application.js my code (which works fine in 3.0) exists, because I've referenced it fine in the new application.js assets pipeline file:
$(document).ready
(function(){
$('input.ui-date-picker').datepicker({
dateFormat: 'dd-mm-yy'
});
});
But it's not being called. Jquery is present, too, and my gemfile got upgraded ok. What could be wrong?
OK, the problem was that I had a number of bits of code within a .js file I'd called various.js, and not all of them were wrapped in $(document).ready... }); Once I added that to each separate bit of code it worked fine. Also, I have to restart the server each time I make a change to the .js file - just touching it doesn't work for me. I found a simple Hello World alert really useful in debugging this (just in case anyone out there is as new to jquery as me!):
$(document).ready(function() {
alert("Hello world!")
});

error on firefox: $.widget is not a function

I have a few multiselect boxes from the Jquery UI on a page that work perfectly well in Chrome & Safari but not in Firefox for some reason... when I load the Error Console in Firefox I see:
Error: $.widget is not a function
Source File: http://localhost:3000/javascripts/jquery.multiselect.js?1302660373
Line: 563
Any ideas why?
edit: the line itself is within the open function right where it says "// react to option changes after initialization"
// open the menu
open: function(e){
var self = this,
button = this.button,
menu = this.menu,
speed = this.speed,
o = this.options;
widget: function(){
return this.menu;
},
// react to option changes after initialization
_setOption: function( key, value ){
var menu = this.menu;
switch(key){
case 'header':
menu.find('div.ui-multiselect-header')[ value ? 'show' : 'hide' ]();
I am assuming you are using the jQuery Multiselect plugin… which depends on jQuery UI.
Sounds like you have not included enough of the jQuery UI library or just none of it. You need to include the core parts of jQuery UI (including Widget) if you build a custom download. Or just download the whole jQuery UI and include it instead.
For anyone else who is getting this but has the requirements; make sure you are including the Javascript files in the correct order. This error was being caused by my jquery-ui.js being included after the multiselect js file.
This answer is probably unrelated to the situation of the questioner, but I put it here for the sake of others Googling the question.
I got this error using Rails 3.2 and fixed it by deleting (renaming) the public/assets folder. It seems there are a lot of problems with the assets pipeline still. I don't know the details but have had other Javascript failures that are fixed this way.
Actually if you are getting this error then it's either
a) per #andyb answer - you haven't included the correct jQuery UI components
OR
b) your DOM is not loaded yet with the correct $.widget and therefore your function is attempting to call before $.widget has loaded. to fix the problem, ensure $.widget is called BEFORE your function

Resources