Search Results

Search found 7898 results on 316 pages for 'underscore js'.

Page 8/316 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • proper way to dynamically assign backbone.js view el

    - by kikuchiyo
    I would like to create two ( or more ) view instances, each with different el attributes, and have events bound to them via backbone.js view's events hash ( not through jQuery ). Getting events to trigger when all instantiations have the same el is easy: someView = Backbone.View.extend({ el: '#someDiv', events: { 'click': 'someFunction' }, someFunction: function(){ //Do something here } }); So far, if I assign el in the initialize function, and set events normally as follows, events do not trigger: someView = Backbone.View.extend({ events: { 'click': 'someFunction' }, initialize: function( options ){ this.el = options.el }, someFunction: function(){ //Do something here } }); My first instinct was to have el be a function that returns the string representation of the dom element of interest: someView = Backbone.View.extend({ el: function(){ return '#someDiv-' + this.someNumber }, events: { 'click': 'someFunction' }, initialize: function( options ){ this.someNumber = options.someNumber }, someFunction: function(){ //Do something here } }); However, this triggers someFunction x times if I have x instantiations of someView. Next I tried setting both the el and events attributes in initialize: someView = Backbone.View.extend({ initialize: function( options ){ this.el = options.el this.events = { 'click': 'someFunction' } }, someFunction: function(){ //Do something here } }); but this does not trigger events. At this point I'm pretty much fishing. Does anyone know how instantiate a backbone.js view with an el specific to that instance that has events that only trigger for that instance, and not other instances of the View?

    Read the article

  • Adding select menu default value via JS?

    - by purpler
    Hi, i'm developing a meta search engine website, Soogle and i've used JS to populate select menu.. Now, after the page is loaded none of engines is loaded by default, user needs to select it on his own or [TAB] to it.. Is there a possibility to preselect one value from the menu via JS after the page loads? This is the code: Javascript: // SEARCH FORM INIT function addOptions(){ var sel=document.searchForm.whichEngine;for(var i=0;i<arr.length;i++){ sel.options[i]=new Option(arr[i][0],i)}} function startSearch(){ searchString=document.searchForm.searchText.value;if(searchString!=""){ var searchEngine=document.searchForm.whichEngine.selectedIndex; var finalSearchString=arr[searchEngine][1]+searchString;location.href=finalSearchString}return false} function checkKey(e){ var character=(e.which)?e.which:event.keyCode;if(character=='13'){ return startSearch()}} // SEARCH ENGINES INIT var arr = new Array(); arr[arr.length] = new Array("Web", "http://www.google.com/search?q="); arr[arr.length] = new Array("Images", "http://images.google.com/images?q="); arr[arr.length] = new Array("Knoweledge","http://en.wikipedia.org/wiki/Special:Search?search="); arr[arr.length] = new Array("Videos","http://www.youtube.com/results?search_query="); arr[arr.length] = new Array("Movies", "http://www.imdb.com/find?q="); arr[arr.length] = new Array("Torrents", "http://thepiratebay.org/search/"); HTML: <body onload="addOptions();document.forms.searchForm.searchText.focus()"> <div id="wrapper"> <div id="logo"></div> <form name="searchForm" method="POST" action="javascript:void(0)"> <input name="searchText" type="text" onkeypress="checkKey(event);"/> <span id="color"></span> <select tabindex="1" name="whichEngine" selected="Web"></select> <br /> <input tabindex="2" type="button" onClick="return startSearch()" value="Search"/> </form> </div> </body>

    Read the article

  • How to handle duplicate values in d3.js

    - by Mario
    First I'm a d3.js noob :) How you can see from the title I've got a problem with duplicated data and aggregate the values is no option, because the name represent different bus stops. In this example maybe the stops are on the fron side and the back side of a building. And of course I like to show the names on the x-axis. If i created an example and the result is a bloody mess, see jsFiddel. x = index name = bus stop name n = value I've got a json e.g.: [{ "x": 0, "name": "Corniche St / Abu Dhabi Police GHQ", "n": 113 }, { "x": 1, "name": "Corniche St / Nation Towers", "n": 116 }, { "x": 2, "name": "Zayed 1st St / Al Khalidiya Public Garden", "n": 146 }, ... { "x": 49, "name": "Hamdan St / Tariq Bin Zeyad Mosque", "n": 55 }] The problem: It is possible that the name could appear more then once e.g. { "x": 1, "name": "Corniche St / Nation Towers", "n": 116 } and { "x": 4, "name": "Corniche St / Nation Towers", "n": 105 } I like to know is there a way to tell d3.js not to use distinct names and instead just show all names in sequence with their values. Any ideas or suggestions are very welcome :) If you need more information let me know. Thanks in advanced Mario

    Read the article

  • Why Backbone.js isn't binding my event

    - by Saif Bechan
    I have a router like this, as main entry point: window.AppRouter = Backbone.Router.extend({ routes: { '': 'login' }, login: function(){ userLoginView = new UserLoginView(); } }); var appRouter = new AppRouter; Backbone.history.start({pushState: true}); I have a model/collection/view like this: window.User = Backbone.Model.extend({}); window.Users = Backbone.Collection.extend({ model: User }); window.UserLoginView = Backbone.View.extend({ events: { 'click #login-button': 'loginAction' }, initialize: function(){ _.bindAll(this, 'render', 'loginAction'); }, loginAction: function(){ var uid = $("#login-username").val(); var pwd = $("#login-password").val(); var user = new User({uid:uid, pwd:pwd}); } }); And body of my HTML looks like this: <form action="#" method="POST" id="login-form"> <p> <label for="login-username">username</label> <input type="text" id="login-username" autofocus /> </p> <p> <label for="login-password">password</label> <input type="password" id="login-password" /> </p> <a id="login-button" href="#">Inloggen</a> </form> Note: The HTML comes from Node.js using express.js, should I maybe wait for a document ready event somewhere? Edit: I have tried this, create the view when ready, did not solve the problem. $(function(){ userLoginView = new UserLoginView(); });

    Read the article

  • Defining and using controller methods in ember.js

    - by OriginalEXE
    first of all, I am total noob when it comes to OOP in JS, this is new to me so treat me like a noob. I am building my first ember.js application and I am stuck (not the first time but I would get unstuck by myself, this is a tough one though). I have two models: forms entries Entries is of course in (one to many) relationship to forms, so each form can have as many properties. Form properties: id : DS.attr( 'number' ), title : DS.attr( 'string' ), views : DS.attr( 'number' ), conversion : DS.attr( 'number' ), entries : DS.hasMany( 'entry' ) Entry properties: id : DS.attr( 'number' ), parent_id: DS.belongsTo( 'form' ) Now, I have forms route that displays all forms in tabled view, and each table row has some info like form id, name etc. and that works great. What I wanted to do is display the number of entries each form has. I figured I should do that via controller, so here is my controller now: // Form controller App.FormController = Ember.ObjectController.extend({ entriescount: function() { var entries = this.get( 'store').find( 'entry' ); return entries.filterBy( 'parent_id', this.get( 'id' ) ).get( 'length' ); }.property( '[email protected]_id') }); Now for some reason, when I use {{entriescount}} in {{#each}} loop, this returns nothing. It also returns nothing in single form route. Note that in both cases, {{title}} for example works. I am wondering, am I going the right way by using controller for this, and how do I get controller to output the data. Thanks

    Read the article

  • problems piping in node.js

    - by alvaizq
    We have the following example in node.js var http = require('http'); http.createServer(function(request, response) { var proxy = http.createClient(8083, '127.0.0.1') var proxy_request = proxy.request(request.method, request.url, request.headers); proxy_request.on('response', function (proxy_response) { proxy_response.pipe(response); response.writeHead(proxy_response.statusCode, proxy_response.headers); }); setTimeout(function(){ request.pipe(proxy_request); },3000); }).listen(8081, '127.0.0.1'); The example listen to a request in 127.0.0.1:8081 and sends it to a dummy server (always return 200 OK status code) in 127.0.0.1:8083. The problem is in the pipe among the input stream (readable) and output stream (writable) when we have a async module before (in this case the setTimeOut timing). The pipe doesn't work and nothing is sent to dummy server in 8083 port. Maybe, when we have a async call (in this case the setTimeOut) before the pipe call, the inputstream change to a state "not readable", and after the async call the pipe doesn't send anything. This is just an example...we test it with more async modules from node.js community with the same result (ldapjs, etc)... We try to fix it with: - request.readable =true; //before pipe call - request.pipe(proxy_request, {end : false}); with the same result (the pipe doesn't work). Can anybody help us? Many thanks in advanced and best regards,

    Read the article

  • Cloud 9 and Grunt.js

    - by Michael Ryan Soileau
    I'm running grunt.js on Cloud9. Most everything is working correctly, except when I try to set this option: 'watch: { options: {livereload:true},' If I add that, the terminal states: 'Fatal error: listen EACCES' I'm guessing I need to use the sudo command to run that and since c9 doesn't let you run sudo, the command fails. But why is livereload a feature that requires permission? And is there any way around it?

    Read the article

  • ext-js chart, multiple series on same chart

    - by user121196
    Ext-js Chart, I have a line graph, and I wish to add a single line(eg. average line) to the graph. The only way I can think of to emulate this line is to do the following: add an extra field with identical value to all my data points if, but this seems to be a waste and plus I don't want to show the dots that comes with the line. is there anyway to add an average line to my existing chart?

    Read the article

  • Detecting wether a point is inside or outside of a raphael.js shape

    - by betamax
    I have a raphael.js shape which I am plotting circle's on top of. I only want a circle to appear if the circle does not go off the boundary of the shape it is being plotted on to. To make this more clear, here is an example of what I do not want to happen: I want the circles outside of the grey area not to appear. How would I detect wether a circle is inside or outside of the grey shape?

    Read the article

  • Node.js appears to be missing the multipart module

    - by Brenton Alker
    I am trying to parse form data, including upload files with a node.js http server. All of the tutorial type articles I have found use a require("multipart"); to include the multipart module, but when I try the same I get: Error: Cannot find module 'multipart' I also can't find it in the current api docs (though it is in the google cached version). So, has this module been removed from the standard installation or is there something else that does the job?

    Read the article

  • Is there any syntax checker for knockout.js?

    - by YMC
    I like knockout.js, the only problem is Visual Studio knows nothing about this framework, so it does not prevent me from silly things like assigning some value to observable property with '=' operator which makes it regular property, and it's not easy to reveal at compile time and often at runtime even. I wonder is there any syntax checker/highlighter for Visual Studio 2010 that helps me prevent faults like this? What about VS 2011? It might be a great help for developers who are new to knockout. Thanks

    Read the article

  • impress.js Navigation with active class

    - by ArtGoddess
    I would like to use impress.js in order to make a website, with a navigation bar. In each slide, the corresponding anchor or div must have an "active" class, in order to achieve a different link appearance. I have followed all instructions provided here: https://github.com/Ralt/impress.js/commit/f88feb8cae704ce27bd2168bdb77768f516ac2da#L2R605 but the "active" class on the correct menu must be added. This is the code that generates the menu items. How can I add for example the "active" class in the first link? /* ************************ MENU ***************************** */ // Capitalize first letter of string // @see http://stackoverflow.com/a/1026087/851498 var capitalize = function( str ) { return str.charAt(0).toUpperCase() + str.slice(1); } // `showMenu` API function creates the menu // It defines the names of each entry by the id capitalized. var showMenu = function() { // Create the menu wrapper and the element that will be cloned // for each entry. var menu = document.createElement('div'), el = document.createElement('div'); // Apply some classes menu.className = 'menu'; el.className = 'menu-item'; // Create an element that will be the "button" and append it // to the menu var button = document.createElement('div'); button.className = 'menu-button'; button.textContent = 'Menu'; menu.appendChild(button); // Now, for each div in #impress, add an entry to the menu [].forEach.call(byId('impress').firstElementChild.children, function( child, index ) { var newEl = el.cloneNode(), i = index + 1, text = i + '. ' + capitalize(child.id); // Set the text of the new element newEl.textContent = text; // Add an onclick event to the new element // We need to use a closure to make sure the index is correct (function( index ) { newEl.addEventListener('click', function() { goto(index); }); }( index )); // And append the new element to the menu menu.appendChild(newEl); }); // And append the menu to #impress document.body.appendChild(menu); }; Then, in each click it must be removed the active class on the current, and add it to the clicked element. // Remove the active class from the current active document.querySelector( '.active' )[ 0 ].classList.remove( 'active' ); // And add it to the clicked index byId('impress').firstElementChild.children[ index ].classList.add( 'active' ); Where do I have to apply this code? Thank you!

    Read the article

  • Using Handlebars.js issue

    - by Roland
    I'm having a small issue when I'm compiling a template with Handlebars.js . I have a JSON text file which contains an big array with objects : Source ; and I'm using XMLHTTPRequest to get it and then parse it so I can use it when compiling the template. So far the template has the following structure : <div class="product-listing-wrapper"> <div class="product-listing"> <div class="left-side-content"> <div class="thumb-wrapper"> <img src="{{ThumbnailUrl}}"> </div> <div class="google-maps-wrapper"> <div class="google-coordonates-wrapper"> <div class="google-coordonates"> <p>{{LatLon.Lat}}</p> <p>{{LatLon.Lon}}</p> </div> </div> <div class="google-maps-button"> <a class="google-maps" href="#" data-latitude="{{LatLon.Lat}}" data-longitude="{{LatLon.Lon}}">Google Maps</a> </div> </div> </div> <div class="right-side-content"></div> </div> And the following block of code would be the way I'm handling the JS part : $(document).ready(function() { /* Default Javascript Options ~a javascript object which contains all the variables that will be passed to the cluster class */ var default_cluster_options = { animations : ['flash', 'bounce', 'shake', 'tada', 'swing', 'wobble', 'wiggle', 'pulse', 'flip', 'flipInX', 'flipOutX', 'flipInY', 'flipOutY', 'fadeIn', 'fadeInUp', 'fadeInDown', 'fadeInLeft', 'fadeInRight', 'fadeInUpBig', 'fadeInDownBig', 'fadeInLeftBig', 'fadeInRightBig', 'fadeOut', 'fadeOutUp', 'fadeOutDown', 'fadeOutLeft', 'fadeOutRight', 'fadeOutUpBig', 'fadeOutDownBig', 'fadeOutLeftBig', 'fadeOutRightBig', 'bounceIn', 'bounceInUp', 'bounceInDown', 'bounceInLeft', 'bounceInRight', 'bounceOut', 'bounceOutUp', 'bounceOutDown', 'bounceOutLeft', 'bounceOutRight', 'rotateIn', 'rotateInDownLeft', 'rotateInDownRight', 'rotateInUpLeft', 'rotateInUpRight', 'rotateOut', 'rotateOutDownLeft', 'rotateOutDownRight', 'rotateOutUpLeft', 'rotateOutUpRight', 'lightSpeedIn', 'lightSpeedOut', 'hinge', 'rollIn', 'rollOut'], json_data_url : 'data.json', template_data_url : 'template.php', base_maps_api_url : 'https://maps.googleapis.com/maps/api/js?sensor=false', cluser_wrapper_id : '#content-wrapper', maps_wrapper_class : '.google-maps', }; /* Cluster ~main class, handles all javascript operations */ var Cluster = function(environment, cluster_options) { var self = this; this.options = $.extend({}, default_cluster_options, cluster_options); this.environment = environment; this.animations = this.options.animations; this.json_data_url = this.options.json_data_url; this.template_data_url = this.options.template_data_url; this.base_maps_api_url = this.options.base_maps_api_url; this.cluser_wrapper_id = this.options.cluser_wrapper_id; this.maps_wrapper_class = this.options.maps_wrapper_class; this.test_environment_mode(this.environment); this.initiate_environment(); this.test_xmlhttprequest_availability(); this.initiate_gmaps_lib_load(self.base_maps_api_url); this.initiate_data_processing(); }; /* Test Environment Mode ~adds a modernizr test which looks wheater the cluster class is initiated in development or not */ Cluster.prototype.test_environment_mode = function(environment) { var self = this; return Modernizr.addTest('test_environment', function() { return (typeof environment !== 'undefined' && environment !== null && environment === "Development") ? true : false; }); }; /* Test XMLHTTPRequest Availability ~adds a modernizr test which looks wheater the xmlhttprequest class is available or not in the browser, exception makes IE */ Cluster.prototype.test_xmlhttprequest_availability = function() { return Modernizr.addTest('test_xmlhttprequest', function() { return (typeof window.XMLHttpRequest === 'undefined' || window.XMLHttpRequest === null) ? true : false; }); }; /* Initiate Environment ~depending on what the modernizr test returns it puts LESS in the development mode or not */ Cluster.prototype.initiate_environment = function() { return (Modernizr.test_environment) ? (less.env = "development", less.watch()) : true; }; Cluster.prototype.initiate_gmaps_lib_load = function(lib_url) { return Modernizr.load(lib_url); }; /* Initiate XHR Request ~prototype function that creates an xmlhttprequest for processing json data from an separate json text file */ Cluster.prototype.initiate_xhr_request = function(url, mime_type) { var request, data; var self = this; (Modernizr.test_xmlhttprequest) ? request = new ActiveXObject('Microsoft.XMLHTTP') : request = new XMLHttpRequest(); request.onreadystatechange = function() { if(request.readyState == 4 && request.status == 200) { data = request.responseText; } }; request.open("GET", url, false); request.overrideMimeType(mime_type); request.send(); return data; }; Cluster.prototype.initiate_google_maps_action = function() { var self = this; return $(this.maps_wrapper_class).each(function(index, element) { return $(element).on('click', function(ev) { var html = $('<div id="map-canvas" class="map-canvas"></div>'); var latitude = $(element).attr('data-latitude'); var longitude = $(element).attr('data-longitude'); log("LAT : " + latitude); log("LON : " + longitude); $.lightbox(html, { "width": 900, "height": 250, "onOpen" : function() { } }); ev.preventDefault(); }); }); }; Cluster.prototype.initiate_data_processing = function() { var self = this; var json_data = JSON.parse(self.initiate_xhr_request(self.json_data_url, 'application/json; charset=ISO-8859-1')); var source_data = self.initiate_xhr_request(self.template_data_url, 'text/html'); var template = Handlebars.compile(source_data); for(var i = 0; i < json_data.length; i++ ) { var result = template(json_data[i]); $(result).appendTo(self.cluser_wrapper_id); } self.initiate_google_maps_action(); }; /* Cluster ~initiate the cluster class */ var cluster = new Cluster("Development"); }); My problem would be that I don't think I'm iterating the JSON object right or I'm using the template the wrong way because if you check this link : http://rolandgroza.com/labs/valtech/ ; you will see that there are some numbers there ( which represents latitude and longitude ) but they are all the same and if you take only a brief look at the JSON object each number is different. So what am I doing wrong that it makes the same number repeat ? Or what should I do to fix it ? I must notice that I've just started working with templates so I have little knowledge it.

    Read the article

  • node.js express app won't start (or debug) in Eclipse (Nodeclipse)

    - by Ultra
    When I do on my app.js Debug As > Node Application it says Launching STANDALONE_V8 has encountered a problem. Failed to connect to Standalone V8 VM connect timed out It should start an app. Doing so directly on my terminal works fine. When I start a debug session in my terminal and than try to debug it in Eclipse works fine too. So is there anything that has to be done in order to make it work in Eclipse?

    Read the article

  • In node.js slow readable stream attached to a faster pushing message queue eats up memory

    - by Vishal
    In my node.js program I have a response stream attached to a message queue (zeromq) delivering data at a very high rate. Due to slow network connection the response stream and its underlying implementation is unable to consume data at that pace thus occupying a lot of memory. Do you have any suggestion to solve this problem. For reference please see the code snippet below: zmq.on("message", function(data) { res.write(data); // End response on some event });

    Read the article

  • Protect js code from being stolen

    - by Kaidul Islam Sazal
    I have developed an web app with jquery,html-css markup which would be an premium web app. So I have to ensure the security of the code from being stolen.But as all these are client side,so there is no 100% secure way to protect them.But I want to make them harder to steal.For this I did : I have disabled the right click button of mouse I have minified and obfuscated the code. I have used js code to add external js file and obfuscated the code so that none can understand the name of the external js file I have created a index.html file in the js folder so that none can get access the js folder Do you think all these are enough to make stealing harder? Or any suggestion/advice for me?

    Read the article

  • Sprite.js surface background

    - by user1086671
    I'm making a tile-based game using Sprite.js. It is not easy to redraw every tile each frame, so I tried to make a scrolling surface background. There is an example here http://batiste.dosimple.ch/sprite.js/tests/test_scrolling.html The example works, but it seems like ScrollingSurface.update is buggy or there is something I'm missing. What I tried to do is to draw 5x5 tiles and after 5 seconds draw another 5x5 tiles near the first ones. But it draws only the first ones. And surface.update() only updates the position of surface. Here is my code https://github.com/Sektoid/sprite.js/blob/master/tests/test_scrolling.html (You need also to set this.divider = 1.0 in scrolling.js to avoid drawing the same tiles 4 times.) There aren't any sprite.js-forums like with the other sprite- and game-engines have, so I'm asking here.

    Read the article

  • WPF, PreviewKeyDown event and underscore char

    - by commanderz
    Hi, I'm catching key hits with PreviewKeyDown event in my WPF component. I need to distinguish characters being typed: letters vs. numbers vs. underscore vs. anything else. Letters and numbers work fine (just convert the Key property of the KeyEventArgs object to string and work with character 0 of that string), but this won't work for underscore. It's ToString value depends on localized keyboard settings (it shows up as "OemMinus" on EN/US keyboard and "OemQuestion" on CZ/QWERTY keyboard). So how can I RELIABLY find out, if the typed char is underscore in the PreviewKeyDown event? Thanks for any help

    Read the article

  • How to remove my backslash while input have underscore

    - by bob
    Problem when I enter any input which has underscore (_) data will store to my db looks like this image\_background.png Example $image = stripslashes($_POST['image']); // example image name image_background.png $query = 'UPDATE product SET image="' . $db->string_escape($image, true) . '" WHERE id="' . intval($id) . '"'; The problem coming when input has underscore only. If without underscore all backslashes will remove by the stripslashes Let me know.

    Read the article

  • Understanding Node.js and concept of non-blocking I/O

    - by Saif Bechan
    Recently I became interested in using Node.js to tackle some of the parts of my web-application. I love the part that its full JavaScript and its very light weight so no use anymore to call an JavaScript-PHP call but a lighter JavaScript-JavaScript call. I however do not understand all the concepts explained. Basic concepts Now in the presentation for Node.js Ryan Dahl talks about non-blocking IO and why this is the way we need to create our programs. I can understand the theoretical concept. You just don't wait for a response, you go ahead and do other things. You make a callback for the response, and when the response arrives millions of clock-cycles later, you can fire that. If you have not already I recommend to watch this presentation. It is very easy to follow and pretty detailed. There are some nice concepts explained on how to write your code in a good manner. There are also some examples given and I am going to work with the basic example given. Examples The way we do thing now: puts("Enter your name: "); var name = gets(); puts("Name: " + name); Now the problem with this is that the code is halted at line 1. It blocks your code. The way we need to do things according to node puts("Enter your name: "); gets(function (name) { puts("Name: " + name); }); Now with this your program does not halt, because the input is a function within the output. So the programs continues to work without halting. Questions Now the basic question I have is how does this work in real-life situations. I am talking here for the use in web-applications. The application I am writing does I/O, bit is still does it in am blocking matter. I think that most of the time, if not all, you need to block, because you have to wait on what the response is you have to work with. When you need to get some information from the database, most of the time this data needs to be verified before you can further with the code. Example 1 If you take a login for example. You have to wait for the database to response to return, because you can not do anything else. I can't see a way around this without blocking. Example 2 Going back to the basic example. The use just request something from a database which does not need any verification. You still have to block because you don't have anything to do more. I can not come up with a single example where you want to do other things while you wait for the response to return. Possible answers I have read that this frees up recourses. When you program like this it takes less CPU or memory usage. So this non-blocking IO is ONLY meant to free up recourses and does not have any other practical use. Not that this is not a huge plus, freeing up recourses is always good. Yet I fail to see this as a good solution. because in both of the above examples, the program has to wait for the response of the user. Whether this is inside a function, or just inline, in my opinion there is a program that wait for input. Resources I looked at I have looked at some recourses before I posted this question. They talk a lot about the theoretical concept, which is quite clear. Yet i fail to see some real-life examples where this is makes a huge difference. Stackoverflow: What is in simple words blocking IO and non-blocking IO? Blocking IO vs non-blocking IO; looking for good articles tidy code for asynchronous IO Other recources: Wikipedia: Asynchronous I/O Introduction to non-blocking I/O The C10K problem

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >