Rendering resolved promise value in Ember handlebars template

Is there a good way to render the result of a promise in a handlebars template? For example, I have the following model: App.TopicItem = DS.Model.extend({ topic: DS.belongsTo(‘topic’), paddedPosition: function() { return this.get(‘topic.course.lessons’). then(function(lessons) { return lessons.indexOf(topicItem); }). then(function(index){ var position = index; if (position < 0) { return; } position = position + 1; […]

Return “True” on Empty jQuery Selector Array?

I’m working on creating a more semantic way of checking for elements with jQuery. Using $(“#element”).length > 0 just doesn’t really feel very well worded to me, so I’m making my own selector addition for use in .is: if($(“#element”).is(“:present”)) { console.log(“It’s aliiiveeee!!”); } That part was easy, like this: $.extend($.expr[‘:’],{ present: function(a) { return $(a).length […]

Calculate empty vertical space in text

I have a span with CSS: font-height = 120px; height = 120px; line-height = 120px; The text within it does not occupy the complete height(120px) of the span. Is there any way to calculate the offset of the text within the span from upper and lower boundaries? Or is this an way to make the […]

Can't find element in DOM after loading it with ajax (want to bind jquery plug in to it)

So I have 2 html pages. 1 that functions as container and 1 that functions as content. When I load the content page with a table I’m able to use drag and drop. But when I go to my container page and load the content page into a div with ajax, the drag and drop […]

How to animate a custom Google Maps marker along a route?

I have written a small application for a handheld device using JavaScript and Google Maps API’s, now II need to move my marker icon anywhere on the map along a route using a timer function. I have a man icon and I need to move it automatically on the map. How can I do this?

JavaScript Regex (string should include only alpha, space, hyphen)

I’m trying to create a regex that will match only when the string has anything but alphas, spaces, and hyphens. In other words, the string can only contain letters, spaces, and hyphens.

How to rearrange elements using jQuery?

How to rearrange elements using jQuery ? Orginal Code : <p id=”paragraph1″>1</p> <p id=”paragraph2″>2</p> <p id=”paragraph3″>3</p> <p id=”paragraph4″>4</p> <p id=”paragraph5″>5</p> After Rearrange (put p3 in p2’s place) <p id=”paragraph1″>1</p> <p id=”paragraph3″>3</p> <p id=”paragraph2″>2</p> <p id=”paragraph4″>4</p> <p id=”paragraph5″>5</p>

React, babel, webpack not parsing jsx code

webpack.config.js module.exports = { context: __dirname + “/app”, entry: { javascript: “./app.js”, html: “./index.html”, }, resolve: { extensions: [”, ‘.js’, ‘.jsx’] }, output: { filename: “app.js”, path: __dirname + “/dist”, }, module: { loaders: [ { test: /\.jsx?$/, exclude: /node_modules/, loader: “babel-loader”, }, { test: /\.html$/, loader: “file?name=[name].[ext]”, }, ], }, } package.json { “name”: […]

How to get the text of the selected option of a select using jquery?

If I have this select: <select id=”days”> <option value=”0″>Today</option> <option value=”1″>Yesterday</option> <option value=”7″>Last week</option> </select> and someone selects the 3rd option ‘last week’, I can get the value of last week (which is 7), using $(“#days”).val(), but how can I get the value of the text i.e ‘Last week’?

Why is the event object different coming from jquery bind vs. addEventListener

Why is it when I use the jQuery bind the event object I get back is different from the event object I get back using addEventListener? The event object resulting from this jQuery bind does not have the targetTouches array (among other things) but the event from the addEventListener does. Is it me or is […]