天道酬勤,学无止境

javascript

Getting Accurate Dimensions for a newly-created DOM object

I'm creating DOM elements dynamically (more specifically, using jQuery to create a DIV containing some text with css "width:auto", and using a "font-face" font, in the page OnLoad event) but find that the width of the div is not the expected size (specifically, the width is wrong) immediately after I create it and add it to the DOM tree. I need to know the width/height of the element because I will be doing some dynamic layout on it. As a workaround, I use the following code after creating the elements: SetTimeout(complete_layout,100) By delaying the completion of my layout with this extra

2021-07-13 17:37:10    分类:问答    javascript   jquery   dom   dynamic   dimensions

jQuery.clone() IE problem

I'm have some that uses jQuery.clone() to get the html of a page and then add it to a pre tag. It works correctly in Firefox and Chrome, but nothing happens in IE: <!DOCTYPE html> <html> <head> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <meta charset=utf-8 /> <title>JS Bin</title> <!--[if IE]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <script> $(function(){ $('button').click(function(){ var $clone = $('html').clone(); $('#output').text($clone.html()); }); }); </script> <style> article, aside

2021-07-13 17:36:16    分类:问答    javascript   jquery   internet-explorer   clone

Ajax submit various input values with jquery UI next button click

I am currently working with jquery ui tabs and ajax/post submit without page refresh. With some guidance I have been able to get the div #wmd-preview submited when clicking the next button. The issue is that I also have other fields I will like to submit at the same time when the next button is clicked in various tabs. How can I submit the input values of various input fields in different tabs when clicking the next button? EXAMPLE (for some testing i currently have the other input fields submit with keyup and timer setup) JS- NEXT/Previous button merged with submit/ajax <script> var

2021-07-13 17:34:01    分类:问答    javascript   jquery   ajax

IE 11 throwing “'timeZone' is outside of valid range” when setting timezone to “Europe/London”

I have some js to get the local time displayed in uk's timezone. var d = new Date(); // local system time (whatever timezone that is) var dUK = new Date(d.toLocaleString('en-GB', { timeZone: 'Europe/London' })); // UK timezone (covers BST too) Works fine in all browsers except IE 11(sigh...) which throws the following error: Option value 'EUROPE/LONDON' for 'timeZone' is outside of valid range. Expected: ['UTC'] Does anybody have any suggestions? See http://jsbin.com/dawaqocuvi/1/edit?html,js,console,output for an example fiddle that supports IE.

2021-07-13 17:31:57    分类:问答    javascript   datetime   internet-explorer   localization   internet-explorer-11

Send javascript variables to rails?

I need to seed a javascript variable to the controller. For example, if my code in the view is the following - ... <script type="text/javascript"> variable_test = 'hello' </script> ... I need the controller to get variable_test , like - def hello @variable_test = #Some code # @variable_test => 'hello' end The view is hello of course, and 'Some code' is what I don't know how to do.

2021-07-13 17:28:41    分类:问答    javascript   ruby-on-rails   ajax

Update a row in Parse.com

What I have is when an edit button is clicked the values in two input fields create a new row and the old row is dropped.Below is the code i used but what i want is that the original row is updated and not deleted. Live Example of how using the code below works. editBtn.onclick = function () { alert("Edit Btn"); alert(name.value + " " + Lname.value); contact.save(null, { success: function (contact) { contact.set("FirstName", name.value); contact.set("LastName", Lname.value); contact.save(); object.destroy({ success: function (myObject) { alert("destroy"); location.reload(); }, error: function

2021-07-13 17:28:09    分类:问答    javascript   jquery   html   parse-platform

How to Update chart in react-chartjs-2?

I call the update() function, but it does not work. TypeError: line.update is not a function. Why is update() not a function? I have seen this example on http://jsfiddle.net/zpnx8ppb/26/ where the update function does work Here is my code: import React, { Component } from 'react'; import { Line } from 'react-chartjs-2'; import Chart from 'chart.js'; const line = { labels: [], datasets: [ { label: 'My First dataset', fill: false, data: [] } ] }; setInterval(function(){ line.labels.push(Math.floor(Math.random() * 100)); line.datasets[0].data.push(Math.floor(Math.random() * 100)); line.update();

2021-07-13 17:23:52    分类:问答    javascript   reactjs   react-chartjs

Convert Javascript app into Windows app

Is there any solutions except Adobe Air? I have heard that V8 kinda have something there. Just don't have time for now, to write on another language whole app and then write 2x more code.

2021-07-13 17:17:59    分类:问答    javascript

how to make function which related comboboxes option

in my html page there are three form input has been related each other. first input as combobox with option: TCA Intasept second and third input as text type. if first input fill is "TCA" when user input in second input "01" so in third input automaticly filled by "1-120". if first input fill is "intasept" when user input in second input "01" in third input automaticly fille by "1-32". on simple logic. first input = "TCA" (selected option by user). second input = "01" (manually input by user). third input = "1-120" (automaticly input). this will continue with interval 120. ex: second input: 02

2021-07-13 17:17:31    分类:问答    javascript   jquery   html

No known route from 'cmyk' to 'srgb' when processing images

CodeSandbox - https://codesandbox.io/s/jj597mrvmw I am having an issue with some data returned from an external API to my GatsbyJS/ReactJS site. More specifically, the issue appears to be when processing the images with gatsby-image and gatsby-plugin-sharp using the API ...GatsbyImageSharpFluid on GraphQL queries. From the 1000's of images, it appears that only 1 is troublesome, returning the error Errors: icc_transform: no input profile vips_colourspace: no known route from 'cmyk' to 'srgb' I could just filter this image out but am concerned that future images as the API updates could cause

2021-07-13 17:15:50    分类:问答    javascript   reactjs   graphql   gatsby