Posts

Showing posts with the label JavaScript

Getting into Electron

Image
Looking for something new and interesting , I decided to take my first, tentative steps into the world of Electron . While I'm quite interested in the possibilities offered by Node.js, I've not actually done much with it, so jumping into Electron is that little bit more daunting. I have spent plenty of time with JavaScript /jQuery though, which is th e important thing. First off is the setting up the basic application structure. Each application has a couple of files essentially describing it and lay ing out beha vior and functions , then at least one more file that contains the visible content. The fi rst file, package.json is a basic description of the application that points to the main file that holds the core . package.json 1 2 3 4 5 { "name" : "testapp" , "version" : "0.1.0" , "main" : "main.js" } In this case (and by default IIRC), the core file is named main.js. First o...

jQuery can be unbelievably handy and concise

Adding selectable table rows in jQuery The short bit of jQuery consists of the following: Adds a .click() function to any tr elements inside a tbody element to toggle the addition of the selected class whenever a row is clicked. Next, another .click() to give a link with the ID selectAll the ability to toggle all rows at once. Finally, one more .click() attached to the ID clearSelected that will deselect any rows currently selected. In this case any tr elements inside a tbody element are selected, but this could be refined using IDs or Classes if there are multiple tables on the page. $( document ).ready( function () { $( 'tbody tr' ).click( function () { $( this ).toggleClass( 'selected' ); }); $( '#selectAll' ).click( function () { $( 'tbody tr' ).toggleClass( 'selected' ); }); $( '#clearSelected' ).click( function () { $( 'tbody tr' ).removeClass( ...