escaping/encoding characters ready for use in an attribute

Context:I want to pass a title field into an angular attribute. The title field is sometimes crazy with the characters people put in.I have the following Csharp property:Model.StoryTitle = "!"£$%^&*()<>;><~andanythingelsethatisweird";<my-directive-thing story-title="@Model.StoryTitle"></my-directive-thing>I also have this on a page that pulls the same field out of an ajax call and gets populated by Kendo (darn legacy frameworks):<my-directive-thing story-title="#= storyTitle #"></my-directive-thing>On my directive side, I have the fol...

How to define constructor function in JavaScript classes?

Well I am well aware that there is no straight way to define classes in JavaScript. There is no class keyword in JavaScript according to this article. But we can stimulate class-like behaviour using the function keyword.Now my question is, Is there any way to define a constructor function like those in C/C++ that will be automatically executed whenever an instance of this not-so-class is created? you can call a constructor(args){} on your class and use it.E.g:class Dummy { constructor(Param){ // what you want }} [XXX]Except InternetExplorer, modern browse...

jQuery Validation using the class instead of the name value

I'd like to validate a form using the jquery validate plugin, but I'm unable to use the 'name' value within the html - as this is a field also used by the server app.Specifically, I need to limit the number of checkboxes checked from a group. (Maximum of 3.) All of the examples I have seen, use the name attribute of each element. What I'd like to do is use the class instead, and then declare a rule for that.htmlThis works: <input class="checkBox" type="checkbox" id="i0000zxthy" name="salutation" value="1" />This doesn't work, but is what I'm aiming for:<input cla...

How do I embed javascript in clojure Hiccup?

I'm writing a webserver app in clojure with Hiccup (and other things).I'm trying to have a check-box enable and disable two drop-down fields with a little JS but I can't make it work.[:head[:script "function toggleText(cb, t1, t2) { document.getElementById(t1).disabled = !cb.checked; document.getElementById(t2).disabled = !cb.checked;}"]][:td (hf/check-box {:on-change (str "toggleText(" (name endtag) "," (name tytag) "," (name tmtag) ")")} endtag)][:td (hf/drop-down tytag (range 2013 2031) 2017)][:td (hf/drop-down tmtag (range 1 13) 6)] on-change is a React handler...

How to cancel an image from loading

Suppose in Javascript that you assign the SRC to an IMG tag. It is a large SRC and you want to cancel it before it has finished loading. Assigning the SRC to another image will not stop the data from loading.That is, in the middle of the load you can assign the SRC to another smaller image and the smaller image will be loaded and appear in your browser. However, the original SRC still continues downloading.Similarly, deleting the IMG node will not prevent the SRC from continuing to download. No guesses please, look at the repro steps.REPRO(1) Load this URL in Chrome in ...

href with you tube video

I want to clcik on below small youtube link and display the big.I want to video1 video2 *video3* video4 to display the video link like this --- this is only display.After click this video then apear in the big video in same page. Also below is the code:I really appreciate your time. thanks<div style="position:absolute;left:20%;top:20%;height:60%;width:60%"><iframe id="myvideo" src="http://www.youtube.com/watch_popup?v=vt4X7zFfv4k" style="position:relative;height:100%;width:100%"></iframe><div style="text-align:center"><a href="#null" onclick=...

css added from remote node.js but not apply on html page

The application on which m working I am calling CSS file from remote server dynamically and remote server side we are using node.js where file loads but not apply CSS on the page.When I try to add the path other than node.js server path it works properly and when I add some CSS from javascript this also works.I tried following option loadCSS = function(href) {var href = "http://192.168.0.64:3001/public/stylesheets/enduserchat.css";var cssLink = $("");$("head").append(cssLink); }; // not working $('head').append('http://192.168.0.64:3001/public/stylesheets/enduserchat.c...

Apollo Client: Upsert mutation only modifies cache on update but not on create

I have an upsert query that gets triggered on either create or update. On update, Apollo integrates the result into the cache but on create it does not.Here is the query:export const UPSERT_NOTE_MUTATION = gql` mutation upsertNote($id: ID, $body: String) { upsertNote(id: $id, body: $body) { id body } }`My client:const graphqlClient = new ApolloClient({ networkInterface, reduxRootSelector: 'apiStore', dataIdFromObject: ({ id }) => id});The response from the server is identical: Both id and body are returned but Apollo isn't adding new ids into the dat...

Redux-thunk: `dispatch is not a function`

So, I'm having an issue with an action returning the above mentioned error (See attached image), instead of updating redux state as expected. What am I overlooking here?actionCreators.jsexport function userToken(token) { console.log('userToken has been fired'); return (dispatch) => { dispatch({ type: 'Graphcool_Token', payload: token }); } }App.js....// Root Queryconst allPostsCommentsQuery = graphql(All_Posts_Comments_Query, { options: { cachePolicy: 'offline-critical', fetchPolicy: 'cache-first', },});export const mapDispatchToProps = (dispa...

HEX to HSL convert javascript

This question already has an answer here: How do you get the hue of a #xxxxxx colour? 4 answers You forgot to multiply the hue by 360.s = s*100;s = Math.round(s);l = l*100;l = Math.round(l);h = Math.round(360*h);var colorInHSL = 'hsl(' + h + ', ' + s + '%, ' + l + '%)'; [XXX]

Highcharts stacked drilldown with n-levels

I am trying to make a column stacked chart along with drilldown but highcharts API doesnt support it as of now it seems. Have done a bit but its not working properly. http://jsfiddle.net/souranil/T6ryr/.Highcharts.setOptions({ lang: { FullScreenButtonTitle: "View Larger Chart" }});$(function () { var chart; $(document).ready(function () { var colors = Highcharts.getOptions().colors, categories = ['Book1', 'Book2', 'Book3', 'Book4', 'Book5'], name = 'AUM', data = [{ y: 6.06, color: '#B7C726', drilldo...

Better approach to re-draw colorized circles in HTML5 canvas, store values in array or recalculate color every time?

I got several objects where every one of them got priority value. Priority value can be between 1(lowest) to 200(higgest). Every value is represented by a color, lowest value got green color "rgba("0","255",0,1)"; and highest value got "rgba("255","0",0,1)";I calculate color value by classic equation where every priority value determine different value(different color). So in the end i got possible chance of 200 different colors in range from green(0) to yellow(100) to red(200) based on priority.My question is: When I'm redrawing on canvas all objects every 100ms. Is it be...

how to get rid of Js Undefined from here?

my code is okay and output comes into console. but in my span tag result(firstname) shows undefined. i can't understand what is the problem. can anyone help me to solve this problem? how can i get rid of this problem?<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Search Baby name</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script> <script src="https://ajax.aspn...

How to start an anonymous asynchronous function in Angular 2/4?

In my Angular 4 component I have a sort method. It's really just as simple as clicking the header of a table and changing the sort order by that column, and ascending/descending. However, there is a call to a service in there which could eventually become quite expensive, so I'm trying to make this call asynchronous. Example:sortColumn(): void { this.service.someExpensiveBlockingOperation(); this.sortOrder = !this.sortOrder; this.data.sort((a, b) => { ... });}I've tried messing with Promises and Observables, as well as Async / Await but without success. I feel l...

Why does console.log not require an argument in this case?

If I use the Fetch API as follows:fetch(url) .then(response => response.json()) .then(console.log)I understand that this would log the result of the previous "then" (the response data), but why does console.log not require any arguments in this case?Is there any technical reasoning or documentation behind this, and can any other built-in methods be used in this nature? Thats simple Javascript, in this case the console.log requires that argument, what happens here is that the then function takes a callback as its first argument and internally executes that callba...

Get the color of one pixel at Photoshop scripts

I am trying to figure out how to get the color of one defined Pixel.In my imagination its shoud look like:color = get.color.Pixel(x,y);Maybe someone can help me with this piece of code? Photoshop's JavaScript API doesn't provide a mechanism like you imagine in your question.You'll need to utilize the Document.colorSamplers.add([x, y]) method, then read each component color value via its properties:The following gist shows how to obtain either rgb or cmyk values for a given x,y coordinate:#target photoshop// Define the x and y coordinates for the pixel to sample.var x = ...

Page 1 of 1879  |  Show More Pages:  Top Prev Next Last