w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » JAVASCRIPT » Page 3
HTML5 canvas touch panning/scrolling?
Sorry, I don't know the exact code required, but if anything, that's slightly better because then the final project is still your own code, and requires you to actually do some stuff yourself. Anyway, the basic idea would be this: var touching; setInterval(function(){ if (not user-touching-screen){ touching=0; } else { if (touching == 0){ touching = 1; ix = where-user-put

Categories : Javascript

Creating a parallax object prototype with jQuery and I keep getting undefined errors on jQuery functions
A couple of things I would do here (working fiddle http://jsfiddle.net/z8upoccm/2/): 1.) It seems that the function is initializing on your jquery object as expected, but then again on regular DOM elements. Only allow jquery elements to pass through. Object.prototype.parallax = function(userOptions){ if(!this.jquery) return false; 2.) You need units on your translate css property element.cs

Categories : Javascript

right way to modify d3.csv to lower case column names
You can use the accessor that d3.csv accepts to specify how you want the row data transformed. The function below takes an object and converts all of its properties to lowercase. The example uses d3.csv.parse() instead of d3.csv() because its more straightforward to demo here, but you can do the same thing with d3.csv(). Unfortunately, this function gets called for every row as opposed to once w

Categories : Javascript

How can i have an evaluation within a scope variable using ngRepeat?
Try this: <div ng-repeat="item in data"> <div ng-repeat="col in columns"> {{col(item)}} </div> </div> And update your columns to: $scope.columns = [ function(item) { return item.firstName + ' ' + item.lastName; } ];

Categories : Javascript

Why do checkbox property show as 'false' (not checked) when checked?
I'm not certain I understand your problem, but maybe this is because the server is treating the defaults on your check boxes differently. In your HTML, you have set the value properties for all the checkboxes to 1, but the value of a check box is not the same thing as the checked property of a checkbox. When you check these boxes you are changing the checked property from missing to true. Perhaps

Categories : Javascript

Image series bar
$(".coins").each(function(){ var $self = $(this); var applyCoins = function(){ $self.empty(); var coins = $self.data("coins"); for (var i=coins-1; i>=0; i--) { var $coin = $("<div></div>").addClass("coin").css("top", (i*20)+"px"); $self.append($coin); } }; $self.on("loadCoins", function(){

Categories : Javascript

Reading dynamic text from stop watch and inserting it back in a div
After experimenting some more i solved it by changing the variable. $(".masterobject").click(function() { $(this).addClass("clicked"); if ($(".masterobject").length == $(".clicked").length){ pause(); $("#success").show(); var recordtime = $("#yourtime").text(); $("#success").html("congratulations your time is" + recordtime) } full code http://

Categories : Javascript

Get value from select and compare with the DB to obtain a price
You are vulnerable to sql injection attacks. Sit back and relax - your problem will become moot when your server gets pwn3d. As well, your code is highly flawed: document.getElementById("ppu").value = "<?php $query->fetch_object(); ?>"; Your fetch call doesn't DO anything useful. fetch will RETURN an object, but since you don't capture that object or output it in any way, the DB row d

Categories : Javascript

JQuery not detecting dynamically added Anchor Tag with AJAX
First Id must be unique, As A. WolF says your HTML is invalid "P element cannot contains a SELECT element", and you need to use event delegation like: $(document).on('çlick', 'a', function(e){ console.log('click'); e.preventDefault(); $companyName = $('#comp_staff option:selected').text(); $companyId = $('#comp_staff option:selected').val();

Categories : Javascript

Gmail REST API - Mark message as read
Try adding ContentType = "application/json; charset=UTF-8" in the code. Also, check this link for the detail information on the error. Let me know if you still see the error.

Categories : Javascript

Working on some Javascript, worked before, changed it, Ctrl+Z'ed it back, stopped working
Correct your input, </input> doesn't exists: <input type="submit" onclick="getURL()"> You can do what you want like this: HTML: <div class="inputField_1"> <input id="urlInput" type="text"/><br> <input type="submit" id="submitUrl"/> </div> <div class="aboutTitleWrap"></div> JQUERY: $("#submitUrl").on("click", function(){ var

Categories : Javascript

OnClick Function which opens my dropdown box
The problem is your select does not have any options in it, therefore it cannot display any data when clicked. If you give your select options then you will be able to pick items. Look at this fiddle: http://jsfiddle.net/zndwsb12/

Categories : Javascript

bookshelf.js relationship hasMany error
I reference my models as strings, and use Bookshelf's registry plugin. var bookshelf = new Bookshelf( knex ); bookshelf.plugin( 'registry' ); Then I define and create a model: var userModel = /*do bookshelf things*/; bookshelf.model( 'User', userModel ); Then when I create a .hasMany, I use a string to reference. users: function() { return this.hasMany( 'User', 'roleId' ); },

Categories : Javascript

jqGrid - disabling inline dropdown on "edit" but not on "add"
The usage of inlineNav is a special case of inline editing, because editRow will be called. Starting with jqGrid 4.5.3 inline editing supports beforeEditRow and beforeAddRow callbacks which was introduced mostly to provide additional customization in case of usage inlineNav. The method beforeEditRow is more interesting, because it will be called in any way of calling editRow. Before providing an

Categories : Javascript

How to call url in jquery from anchor tag?
Did you try the following ? <a id="lp1" href="Music/Linkin_park.mp3">Play Linkin park</a> <a id="lp2" href="Music/Linkin_park2.mp3">Play Linkin park2</a> <a id="lp3" href="Music/Linkin_park3.mp3">Play Linkin park3</a> And then calling $("#lp1").click(); with a onClick() method for playing each song. Or maybe you looked for something like this : var songto

Categories : Javascript

To disable back button in popup window
My opinion is that ; you shouldn't do it because of causing bad user engagement. It also makes your page untrustable. But for chrome and firefox this should be work; Put This script on head of your page and change 'pagename' to your page name. <script type = "text/javascript" > history.pushState(null, null, 'pagename'); window.addEventListener('popstate', function(event) { hi

Categories : Javascript

Uncaught TypeError: Cannot read property 'lat' of null Exception
Something to try - compose waypts with oResponseData.reduce() as follows : var waypts = oResponseData.reduce(function(a, waypoint) { var lastpoint = a[a.length - 1]; if( !lastpoint || !waypoint.equals(lastpoint.location) ) { a.push({ location:waypoint, stopover:true }); } return a; }, []); This should be more reliable though I'm not sure if it will fix the problem. You c

Categories : Javascript

Which JS added inline styles?
If you are using chrome, you can right-click the DOM element you want to watch (in the element inspector of the dev tools), and select Break On - Attributes Modifications. That's about the closest solution I know of.

Categories : Javascript

changing colors of google bar chart and convert data into percentage
To get the colours you need to change your first line of the array: Change ['Year', 'Sales'], To: ['Year', 'Sales', { role: 'style' }], then each value add the colour to the end like: ['2004', 1000, 'blue'], ['2005', 1170, '#cccccc'], I think you will have to program the percentage yourself. Im looking to do the same and cant find any examples.

Categories : Javascript

Javascript tokenised list to associative collection
Yes, a simple for loop would be the best way to do this: var str ="Rock,Paper,Scissors", arr = str.split(","), obj = {}; for (var i = 0; i < arr.length; i++) obj[arr[i]] = i; The result: console.log(obj); -> Object {Rock: 0, Paper: 1, Scissors: 2} Here our for loop takes up a measly 2 lines of code. There really isn't much need to simplify this further. If you really wante

Categories : Javascript

Multiple attr jquery
add a json encoded array to your data-filter by jQuery('.filters li').data('filter', jsonEncodedArray); EDIT: In php you can encode to a json array like this: $array = array(84,95,10); echo json_encode($array); In javascript: var array = [84,95,10]; var jsonEncodedArray = JSON.stringify(array);

Categories : Javascript

JQuery iterate over array of dictionaries
the jQuery $.each function is just a wrapper for javascripts for-in loop. The object you are trying to iterate is invalid. The loop is looking for key and value based on that key. but the value u'111' is invalid js object notation. Edit: You say you removed the 'u' but the error messages still says you have it...

Categories : Javascript

Meteor / Mongo - How do you Reference a Lookup Collection? (de-normalize vs normalize)
Here is the solution I came up with. I welcome any alternative / Meteor best practice methods. First: I implemeted reactive publist (package) as outlined in this article (https://gentlenode.com/journal/meteor-6-reactive-and-nonreactive-join-with-mongodb/12). This was a great help as it allows the server to push down changes t a page that has already been rendered. Second: I implemented the bel

Categories : Javascript

"Uncaught ReferenceError: Template is not defined" (same for Router, Meteor, Mongo)
For template undefined error, try run meteor reset command and then start server with meteor Note: meteor reset will do reset your build and also local mongodb data Update: It should remove the error but anyways try full uninstall of meteor from your system and install it again. The meteor core installation might get corrupted while auto updating from 0.8 to 1.0 version Uninstall meteor -

Categories : Javascript

Retrieve only the Number from an ID field
Rather than parsing the string, can you use a data attribute? <li id="item_1_dish" data-id="1">Item 1</li> Then to access it if element is a jQuery object: var id = parseInt($element.data('id')); or if element is an HTMLElement: var id = parseInt(element.dataset.id);

Categories : Javascript

Dropzone.js with Rails 4: "Template is missing" error
dropzone sends request in JSON format, but you try to render HTML, so you have to change your controller: from def create @project = Project.find(params[:project_id]) @project_image = @project.project_images.create(project_image_params) redirect_to project_path(@project) end to def create @project = Project.find(params[:project_id]) @project_image = @project.project_images.create(

Categories : Javascript

Don't understand why you should not use an object literal at the beginning of a statement
An object literal starts with { { name: "Paul" age: 30 } // I wish But so does a block. { if (age < 30) console.log ("He's lying again"); } When the interpreter sees "{" it has to pick one interpretation (*). It picks "block" and tries to parse your object literal as if it was code. Which it isn't and so things quickly go wrong. (*) Well, it doesn't have to, it could look ahead to see if

Categories : Javascript

Precompose multiple layers in OpenLayers 3
Use two layers in the map, as in the ol3 layer-spy example. The first layer is the background layer. The second layer, which is above the first layer, is the spy layer. And to change the background layer you can use: map.getLayers().setAt(0, newBackgroundLayer); To change the spy layer: And to change the background layer you can use: map.getLayers().setAt(1, newSpyLayer);

Categories : Javascript

Know which column is currently sorted in Bootstrap DataTables
Figured it out. Must use: var oTable = $('#YOURTABLENAME').dataTable(); var oSettings = oTable.fnSettings(); This gets the settings for the DataTable. Then you can use something like: sortEventFired(oSettings.aaSorting); Because aaSorting gives you the column index and direction example: 1,asc Look here and here under fnSettings and finally here

Categories : Javascript

Fetching JSON Data and passing to Directive Angularjs
Usually need to set a watcher on a scope variable in the directive and wait for the data to come into the controller, something like this. I know nothing about AMCharts, but this is the way I do it with D3, usually. . . .directive('randomDirective', function() { return { scope: 'myData', replace: true, link: function ($scope, element, attrs) { //the true parameter at

Categories : Javascript

Isolated scope binding doesn't work when updated inside a $scope.$watch
You're sending in a Number which is not an object and therefor not bound by reference. Put it as a property of an object instead and pass that into the directive: $scope.obj = { x: 5 };

Categories : Javascript

How to use single click event for multiple button id in jquery
Just separate the IDs by a comma: $(document).on('click', '#frm_submit1, #frm_submit2', function(event) { }); jsFiddle example

Categories : Javascript

How to get a list of files loaded by browser with last request using javascript?
I do not know if this is a neat solution, but with jQuery you could do something like this: $('script').each(function(){ var file = $(this).attr("src"); $( "#result" ).append( file + "<br />" ); }); $('link').each(function(){ var file = $(this).attr("href"); $( "#result" ).append( file + "<br />"); }); $('img').each(function(){ var file = $(this).attr("src"); $( "#result" ).appe

Categories : Javascript

Vectorize canvas drawing
The canvas is a raster surface. If you are treating it as a vector surface then you will need to record all of the operations applied in a separate data structure and send that to the server. You may find that using SVG makes more sense than canvas in your case.

Categories : Javascript

Javascript "document.getElementById" wildcard loop?
Short answer: no, this is not possible. As Markai has pointed out, it is possible. I still feel like using a class is more appropriate, as this better captures the semantics. A bit longer answer: perhaps you can give each element a class="page". Then you can hide all elements with that class and only display the one you're interested in. You can get elements with class 'page' by using document.ge

Categories : Javascript

Polymer ready() and event listeners
You question is missing how you use those pm-list and pm-tabmenu elements. Do you use them inside another Polymer element or directly in the body ? I would also recommend to use data-binding rather than events (you can publish the selected property of the paper-tabs element in your pm-tabmenu element and bind against it. If you want to use custom events and the pm-list and ´pm-tabmenu` elem

Categories : Javascript

inserting active class between tabs
/* Get DOM elements */ var navElement = $('.tabs-btn li a'); var contentElement = $('.tabs-content-container .tab-content'); /* Notify about a click event */ navElement.click(function(e) { /* stop browser from following clicked link */ e.preventDefault(); /* get content div id */ var href = $(this).attr('href'); /* turn off all nav links and turn on the clicked one */

Categories : Javascript

Threejs PlaneGeometry doesn't receive shadows or reflections
Ok I figured it out thanks to this post. The trick is to use the THREE.FlatShading shader on the material. Important to note is that after every update of the vertices two things need to be done. Before rendering geometry.normalsNeedUpdate must be set to true so the renderer also incorporates the newly oriented vertices. Also geometry.computeFaceNormals() needs to be called before rendering becaus

Categories : Javascript

extjs3.4: How to access items in a panel that do not have id/itemId
you can use the following code to access tabpanel without using id or items id this.up().items.items[1] to test the above code I am alerting the title of the tab panel by following code alert(this.up().items.items[1].title); it will alerts the title of the tab panel

Categories : Javascript




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.