w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » JAVASCRIPT » Page 4
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

Javascript instance variable showing as undefined
This is a result of this changing in your code. Inside the forEach block 'this' refers to a different object, so you're adding all that HTML to a completely different object. A simple fix is to save off a reference to this: Workout.prototype.videoCallBack = function(response, item) { var self = this; self.offset = response.offset; if(response.videos) { jQuery(response.vid

Categories : Javascript

timed rectangle animation javascript
Have you though about css animation? It can come really handy, and has a better performance than javascript. You can use transitions on position, and even delay if you don't care about IE9 and before. If you do, you should initiate the animations with javascript by adding a class to each boxes, and that would make it cross-browser. Bassic css mockup for this would look something like this: .b

Categories : Javascript

ng-repeat not working in angular
The {{ curlies are being parsed by laravel, you have to change interpolation in angular. myApp2.config(function($interpolateProvider){ $interpolateProvider.startSymbol('{[{').endSymbol('}]}'); }); and then use {[{ and }]} for the angular part of variables.

Categories : Javascript

array reference javascript angular
OK, so more code does help. It looks like you have asynchronous logic happening here. loadTiming is fired, which does a POST and then a splice on the Times array. One console.log could be firing before this POST and the other after. There's no easy way to tell. One possible fix would be to only log these once the loadTiming async process runs. Return a promise from the loadTiming function an

Categories : Javascript

Passing a PHP variable into flot Bar chart
If $studentages is an array of integers, this means that var data = [ 0, [1, 2, 3, 4, 5]]; This is not the correct format for flot data which expects an array of arrays. So, try: var data = $.map(<?php echo '['.implode(", ", $studentages).']'?>, function(val, idx){ return [[idx, val]]; }); var dataset = [ { label: "Exams By Student Age", data: data, color: "#5482FF" } ]; va

Categories : Javascript

Add filesize or hash after URL to get correct caching
I dont know where you got access to but i assume you can use php. So you should append an md5 (generated by md5_file()) as parameter to your string. The parameter will only change, if you upload a new pdf (mtime() will have the same effect)

Categories : Javascript

Fire 2 actions with ONE click on a button
if you want to assign 2 different actions on one button, set it 2 different classes (or IDs), lets say <div class="action1 action2"> After, in jQuery you will be able to do: $('.action1').on('click', function (e) { console.log('#1'); ... }); $('.action2').on('click', function (e) { console.log('#2'); ... }); JsFiddle: http://jsfiddle.net/g2wdd2cb/

Categories : Javascript

Website not rendering after ember js implementation
Youre missing a few ideas of ember - Naming is important. You have posts - which should be in a model and then use the fixture adapter to declare them. You have a posts template but no posts route defined or in your router. this.resource("posts", {path: "/posts"}, function(){ this.resource("post", {path: "/:post_id"}); }); You have no index route in your router. this.resource("index", {p

Categories : Javascript

Angular services and browserify
One disadvantage to doing this is writing unit tests. It will be difficult to mock your dependencies if you are simply requiring them rather than using Angular's dependency injection. This is somewhat of a dealbreaker for me because one of the many benefits of using Angular is the testability of the framework.

Categories : Javascript

Highcharts JS - heatmap set gridLineWidth
I would suggest to go with the axis min : 0, max : 1, gridZIndex : 10, gridLineWidth : 1, Take a look at this, maybe you find out, how to make it work as you want it. http://jsfiddle.net/u765vneL/

Categories : Javascript

snap.svg drag "real" position
You can do this by grabbing the bounding box of the element being moved, and then change the attribute to that. So the additional code would be... var bb = this.getBBox(); line.attr({ x2: bb.cx, y2: bb.cy }) jsbin You can also get rid of the matrix stuff... jsbin

Categories : Javascript

enableling spyjs code completion in phpstorm
Spy-js 2.0 features (including autocompletion) are available in PhpStorm >=8.0.2. At the moment it's not released, but EAP build is already available, just install it and spy-js plugin will suggest you to update it.

Categories : Javascript

Changing JavaScript into jQuery - createElement
Change your dom object to a jQuery object by calling $(newdiv) and re-initialise the resizable and draggable functionality on the new content. function addnewbox() { var newDiv = document.createElement("div"); var h = document.createElement("h3"); var text = document.createTextNode("MS"); newDiv.appendChild(h); newDiv.className = "ui-widget-content"; h.appendChild(tex

Categories : Javascript

could not show tooltip on mouse over , jquery1.11
You have it working, you just need to apply a title="" attribute to the items you want to have a tooltip. <td class="sample-two">Row1 <img class="one" src="http://ssl.gstatic.com/gb/images/b_5dae6e31.png" width="15" height="15" alt="" title="testing"/> Working JSFiddle: http://jsfiddle.net/ubKtd/1132/ row1's img says testing. Also I suggest visiting: http://jqueryui.com/tooltip/

Categories : Javascript

Conditionally serving different javascript for different screen sizes
you can use wurlf to check in what platform you are. and use require.js to load the module.

Categories : Javascript

How to validate a strict URL
Some validations were removed in Parsley 2.x and Url strict was one of them. However, you can still download version 1.2.3, navigate through the source code and check what was the regular expression used to validate a strict url. With that regular expression, you can create a custom validator in v2.x. Having done that, you should end up with the following code: <input type="text" name="url"

Categories : Javascript

How can I use Tracker.autorun in a static non-Meteor page?
I have isolated Tracker and all of its dependencies down to a single library you can refer to here: https://s3.amazonaws.com/www.chicagogrooves.com/js/meteor-reactive-packages.js This gives you Tracker, ReactiveDict, ReactiveVar, and their dependencies EJSON and Base64 in a single library (41Kb raw unminified, 11Kb gzipped). The only dependency I did not include is UnderscoreJS, as you may want t

Categories : Javascript

create dynamic image with php
With wkhtmltoimage you can convert HTML to an images. You would need a VPS to run it on though. You can then create the HTML and call wkhtml2image via PHP to convert the given HTML to an image.

Categories : Javascript

Change data in PDF from HTML/JS
I think what you want to do is creating a new pdf, inserting the template and name and stuff. But I do not think it is possible with Javascript alone, but with an ajax call to your server. PHP for example got TCPDF library which is relatively easy to use.

Categories : Javascript

Why not run?(Capitalize the first letter of every word)
Try this, if id resualt is correct. I have set fiddler to test. document.getElementById("resualt").innerHTML = str.replace(/wS*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); Demo

Categories : Javascript




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