javascript,dust.jsRelated issues-Collection of common programming errors
Vzlotea
javascript jquery joomla mootools
Please help me with a form I’m trying to do.I have a dropdown select, all the options in the < select > have ID’s, for example: one option has id=”hide_me”, other option has id=”hide_none”.Here is the JS that I have for the form:<?php $script = “window.addEvent(‘domready’, function() { $(‘recipe’).addEvent(‘change’, function(event) {if ( $(‘recipe’)document.getElementById(‘hide_it’).selected === true ) {$(‘hide_me1’).setStyle(‘opacity’, ‘1’);$(‘hide_me2’).setStyle(‘opacity’, ‘1’);} }); $(‘
avetisk
javascript string truncate
How do I truncate a string after or before a pattern? Say if I have a string “abcdef” I need to truncate everything after “abc” so the output will be: defand if i say truncate before “def” the output should be:abcBelow is the code that I triedvar str1 = “abcdefgh”; var str2 = str1.substr(str1.indexOf(“abc”), str1.length); console.log(str2);I didn’t get the output.I’m stuck here any help will be much appreciated.
Canna
javascript jquery ruby-on-rails ajax
Trying the basic stuff,request with data and response with data and print it with jQuery and RailsThis is the front code.$(“#internal_btn”).click(function() {//window.alert(“clicked internal btn!”);$.ajax({type: “POST”,contentType: “application/json; charset=utf-8”,url: “/room/test”,//data: “{‘data1’:'” + value1+ “‘, ‘data2’:'” + value2+ “‘, ‘data3’:'” + value3+ “‘}”,data: {name:”ravi”,age:”31″},dataType: “json”,success: function (result) {//do somthing herewindow.alert(“success!!”);},error: fun
Nick
javascript arrays
var fruit = [“apple”,”pear”,”pear”,”pear”,”banana”];How do I remove all “pear” fruit from this array? I tried the following, but still one pear remains:for(var f in fruit) {if ( fruit[f] == “pear” ) {fruit.splice(f, 1);} }for(var f in fruit) {document.write(fruit[f]+”<br>”); }Outputs:apple pear banana?What am I doing wrong? Live demo: http://jsfiddle.net/SbxHc/
Ohgodwhy
javascript
The function only work in the first time and not working after refreshed the page. The error message from website console is:Uncaught ReferenceError: submit_photo is not defined AddDeletePhoto.php?exhibit_id=2:1onclickUncaught SyntaxError: Unexpected token ILLEGALthis is the onlick html:<a data-role=”button” data-theme=”b” href=javascript:void(0)” onclick=”submit_photo(); return false;”>Upload</a>this is the JS:<script type=”text/javascript”>function submit_photo() {alert(“test
MWA
javascript jquery html5 canvas
I have a very nice pie/donut chart drawn with chartjs.org. Works great. Easy to implement. Animates nicely. I also have a label that needs to update when the user hovers over the chart. Mousemove fires and returns the rgba coordinately as expected in FF and IE10/9. But not Webkit. It seems to get all mixed up… Unexpected behavior coming from Chrome/Safari. Any idea how to fix this?This is the where the problem exist:var canvasOffset = $(this).offset(); var canvasX = Math.floor(e.pageX – canvas
Ben
javascript json node.js object asynchronous
I am new to Node and struggling to access a simple JSON object. My request.body will have JSON content similar to the following:{“store_config”: [{“name”: “hello”,”name2″: “world”}] }The “store_config” value will always be present, however the keys and values within could be anything.How can I iterate through the keys and values to access each? I would also like to process each in an asynchronous manner.Appreciate any thoughts or direction.UPDATEconsole.log(typeof(request.body));Returns: Objectp
Andrei Suceava
javascript jquery
I’ve been struggling with this issue for a while now. Maybe you can help.I have a table with a checkbox at the beginning of each row. I defined a function which reloads the table at regular intervals. It uses jQuery’s load() function on a JSP which generates the new table.The problem is that I need to preserve the checkbox values until the user makes up his mind on which items to select. Currently, their values are lost between updates.The current code I use that tries to fix it is:refreshId = s
Zeynel
javascript scope google-chrome-extension
This question is about a similar javascript scope problem that I asked yesterday. I hope you can help me resolve this issue.I am working with a Chrome extension. options.html saves to localStorage a new user email as “user” and calls refreshUser() function in background.html://save entered gmail address document.getElementById(“save”).addEventListener(“click”, function (){var user = document.getElementById(“getEmail”).value;localStorage.setItem(“user”, user);chrome.extension.getBackgroundPage().
David Faux
javascript google-visualization
I am trying to program a bar chart using Google Visualizations.https://developers.google.com/chart/interactive/docs/gallery/barchartThe bar chart is dynamically generated and changed several times.Google Visualizations seems to have trouble detecting the dimensions of a div element that I dynamically appended via jQuery. Hence, I would like to hard code the dimensions of the bar chart into the options that I feed into Google Visualizations. How do I do that?I have tried these options.var options
AVP
html web jade dust.js
I’ve been looking all over for something that will let me precompile static websites using Grunt. It needs to have partials, so I can include things like a common header/footer across the pages.So far, I’ve only really found Jade, which has a grunt plugin, and this plugin for Grunt that compiles Dust.js templates to static HTML. I don’t really like Jade’s syntax, and the Dust plugin for Grunt is less than ideal. Any suggestions for a good static HTML templating language with Grunt support?
ergoon
javascript node.js mongodb mongoose dust.js
I have a dust.js template that should render a JSON object coming from a mongodb collection.{“author”: “Leslie Horn”,”title”: “An Awesome 132-Cube Ice Tray Exists Because People Are Assholes”,”published”: “2013-06-13T21:00:00.000Z”,”link”: “http://gizmodo.com/an-awesome-132-cube-ice-tray-exists-because-people-are-513229668″,”feed”: {“link”: {“xml”: “feed/http://feeds.gawker.com/gizmodo/excerpts.xml”,”html”: “http://gizmodo.com”},”title”: “Gizmodo”},”summary”: “<p><img alt=\”An Awesome 1
Elankeeran
node.js express dust.js
In expressjs, Dustjs Multiple templates not working getting 500 Error: Template Not Found: templatemy base dust template as below (template.dust)<div class=”page”>{+pageHeader}Hello World!{/pageHeader}<div class=”bodyContent”>{+bodyContent/}</div><div class=”footer”>{+pageFooter}<hr><a href=”/contactUs”>Contact Us</a>{/pageFooter}</div> </div>And I am trying to call this base template inside my home.dust I am getting error as belowExpress 500
PeeHaa
php jquery dust.js
Current I did the dustjs in client javascript as below<!DOCTYPE html> <html> <head><script src=”lib/dust-full-0.3.0.min.js” type=”text/javascript”></script><script src=”vendor/jquery-1.7.1.min.js” type=”text/javascript”></script><script type=”text/javascript”>$(document).ready(function(){// JSON response from server var json_object = { “profile_skill”: “Profile Skill”,”skills”: [{ “name”: “JavaScript” },{ “name”: “Ruby” },{ “name”: “Java” }]}// re
nalply
html dust.js
The partials were used in the this way but I was getting output as undefined. Created two template files parent and child that inherits from parent.parent.tl:<div><span><label>{+title}New{/title}</label></div>child.tl:{>”parent”/}{<title}{#t}<p>NEW {title1} For the Child</p>{/t} {/title}I compiled those templates using dustr and included as .js in my HTML.<script src=”https://raw.github.com/akdubya/dustjs/master/dist/dust-full-0.3.0.min.js”&g
godspeed
dust.js
I’ve just started using dust.js. And I’ve come across a problem. I need to specify a condition (json parameters existence) in template. Depending on it some inner html should be rendered or not. So according to the description I should use smth like this:{?param_name} … {:else} {/param_name}But I need to check a complex condition, so I go for logic helper – {@if..}. And it turns out that I’d like to use path in condition. So.. The result looks:{@if cond=”{myObject.property1} || {myObject.prope
Kevin Leary Boston WordPress
javascript jquery asp.net-mvc json dust.js
I’m working with jQuery 1.8.2 & Dust.js v1.1.1 for MVC-style templating within a JavaScript app. When I use the {@gt} logic helper I receive the following console error:Uncaught TypeError: Cannot read property ‘gt’ of undefinedI believe the proper syntax is used in my template:<ul class=”listview”> {#seasons}<li><h3>{name}</h3><p class=”desc”>{id}</p>{@gt key=”months” value=”0″}<span class=”count”>{months}</span>{/gt}</li> {/seasons} <
Jim
javascript dust.js
I’m using the full, Linked In version 1.2.0 of dust.js and am trying to define a filter for use when rendering a JSON view with a dust template. When I include this line in the page script:_.extend(dust.filters, {foo: function(value){ return ‘foo’; }});it results in this error in Chrome’s debugger:Uncaught ReferenceError: _ is not defined If I add the filter definition to where the other filters are in the dust .js file, it works. What am I doing wrong?
Jim
javascript dust.js
I’m trying to render HTML using compiled templates with dust.js in a browser (not server-side with node.js). If I compile the template in the client-side javascript, it works fine. If I pre-compile the template and include it as a script tag as recommended, the dust.loadSource statement results in the Chrome debugger saying: “Uncaught ReferenceError: nowork is not defined”, where “nowork” is the template name. So…This HTML and script works:<!DOCTYPE html> <html lang=”en”> <head&
Web site is in building