Jump to content

Search the Community

Showing results for tags 'objects'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 4 results

  1. I recently used PHP's json_encode( ) function to covert an array created with PHP into a JSON encoded object, as the conversion appeared normal, I then assigned the value to a Javascript variable using PHP's echo construct and reproduced it with a JS alert. This too, appeared normal. My difficulty arose when I tried using the jQuery .map( ) method to convert my nested Javascript object into a nested Javascript array. I received the following error message in my Console: TypeError: e is not an Object. (evaluating 't-1 in e') Am I being foolish to believe that I need a nested array when I already have a nested object? If not, is there not a routine to perform this very conversion?
  2. Can't get removeEventListener working

    Hello I've been messing around with a small script i've put together from reading various different turorials about drag and drop. I just cannot get removeEventListener to work.. Basically you can begin dragging but the element is stuck on the mouse and you cannot drop it. I've been able to set a variable to toggle on and off to stop it from dragging but I want to understand how to use removeEventListener incase I need it in the future. I appreciate any help. I've posted all of the code at the following JS Fiddle, however for some reason the dragging won't work at all on JS Fiddle: (sorry I'm new to js fiddle) http://jsfiddle.net/7wpxa4tm/ That exact same code does work for me on all browsers back to IE9. It will begin dragging, and then the remove listener which is in the "ignore" method just will not work. Does anyone see any obvious reason for this? I've been messing with this for two days, I've read around a bunch and thought that I realized my problem when I found that you can't use anonymous functions as callbacks as I was previously doing, but even after setting my callbacks to variables it still won't work. Here is the code posted below if that is prefered: EDIT: Sorry the problem is located in D.drag.release() EDIT 2: JFiddle is now loading, had the onload setting wrong, now you can see the problem with the remove listener http://jsfiddle.net/7wpxa4tm/6/ var DragElement = function() {var D = this;this.elem = null;this.offsetX = 0;this.offsetY = 0; this.init = function() { D.anch = document.getElementById('drag-anchor'); D.elem = document.getElementById('wig'); console.log('D.init()'); var call_back = function(event) { console.log('mousedown'); D.drag.anchor(event); }; D.listen(D.anch, 'mousedown', call_back); } this.listen = function(elem, evt, handler) { if (elem.addEventListener) { elem.addEventListener(evt, handler, false); return true; } else if (elem.attachEvent) { return elem.attachEvent('on' + evt, handler); } else { evt = 'on'+evt; if(typeof elem[evt] === 'function'){ handler = (function(f1, f2){ return function(){ f1.apply(this, arguments); f2.apply(this, arguments); } })(elem[evt], handler); } elem[evt] = handler; return true; } return false; } this.ignore = function(elem, evt, handler) { if (elem.removeEventListener) { elem.removeEventListener (evt, handler, false); } if (elem.detachEvent) elem.detachEvent ('on'+evt, handler); } this.drag = { 'dragging' : false, 'release' : function(event) { //D.drag.dragging = false; I can use this dragging boolean to control if it drags or not..but I want to know how to use the remove listener /******** the following remove event method (ignore) will not work...*****/ var call_back = function(event) { D.drag.move(event); }; D.ignore(D.anch, 'mousemove', call_back); }, 'anchor' : function(event){ D.drag.dragging = (D.drag.dragging) ? false : true; D.offsetY = event.clientY-parseInt(D.elem.offsetTop); D.offsetX = event.clientX-parseInt(D.elem.offsetLeft); var call_back = function(event) { D.drag.move(event); }; D.listen(D.anch, 'mousemove', call_back); }, 'move' : function(event) { if(!D.drag.dragging) return; D.elem.style.position = 'absolute'; var top = (event.clientY-D.offsetY); var left = (event.clientX-D.offsetX); D.elem.style.top = top + 'px'; D.elem.style.left = left + 'px'; var call_back = function(event) { D.drag.release(event); }; D.listen(D.anch, 'mouseup', call_back); } }}var drag = new DragElement();drag.listen(window, 'load', function(event) { drag.init(event);}); EDIT 2: JFiddle is now loading, had the onload setting wrong, now you can see the problem with the remove listener http://jsfiddle.net/7wpxa4tm/6/ Edit 3: I just tried returning the removeEventListener function and outputting it to the console, it is "undefined" I guess the problem is how I am passing the function in, or saving the function, but I don't see a way to do it differently
  3. Hello, I'm trying to make a method that creates objects of a parameterized type randomly, but also to store the hashCode of different objects created and if at any time the percentage of different objects is less than 50% throw an exception. This last part is where I've gotten stuck. I have created a population property where I store the different hashCodes and update it in the method adding the new hashCode from the new object. But I don't know how to do for to know if the percentage of different objects is less than 50%. See if someone can help me out. Regards!
  4. I've kind taught myself PHP whilst looking online for examples. I use classes, I just wonder if I'm setting up my classes the right way. Do you have to explicity give a class access to another class in the way I've done below?: $db = new dbConnectionMSSQL();$systemLog = new systemLog();$clubTickets = new clubTickets();$Customers = new Customers();$Events = new Events();$TicketOrders = new TicketOrders();$PlacesOfInterest = new PlacesOfInterest();$Tonight = new Tonight(); $clubTickets->db = $db;$clubTickets->Customers = $Customers;$clubTickets->Events = $Events;$clubTickets->PlacesOfInterest = $PlacesOfInterest;$clubTickets->TicketOrders = $TicketOrders;$clubTickets->Tonight = $Tonight; That's what I've been doing up until now. Is there a more efficient way to do it? Every time I create a new class, I need to copy the bold coce above for that class. Or is that just life in PHP?
×