Results 1 to 3 of 3
  1.    #1  
    Could someone please explain to me why my buttons aren't acting separately.

    first-assistant.jsjsjs
    Code:
    function FirstAssistant() {
    }
    
    FirstAssistant.prototype.setup = function() {
    	var currentTime = new Date();
    	var month = currentTime.getMonth() + 1;
    	var day = currentTime.getDate();
    	var year = currentTime.getFullYear();
    
    	//displays the date
    	this.date=(month + "/" + day + "/" + year);
    	this.controller.get('divIdcount').update(this.date);
    	this.buttonAttributes = {};
    	this.InbuttonModel = {
    		buttonLabel : 'CLOCK IN',
    		buttonClass : '',
    		disabled : false
    		};
    
    	this.controller.setupWidget("IN", this.buttonAttributes, this.InbuttonModel);
    	Mojo.Event.listen(this.controller.get('IN'), Mojo.Event.tap, this.handleButtonPress.bind(this));
    
    
    //set up the clock out buttons
    	this.OutbuttonAttributes = {};
    	this.OutbuttonModel = {
    		buttonLabel : 'CLOCK OUT',
    		buttonClass : '',
    		disabled : false
    		};
    
    	this.controller.setupWidget("OUT", this.buttonAttributes, this.OutbuttonModel);
    	Mojo.Event.listen(this.controller.get('OUT'), Mojo.Event.tap, this.handleButtonPress.bind(this));
    };
    
    FirstAssistant.prototype.handleButtonPress = function(event){
    	// Get the time!
    	var currentTime = new Date();
    	var hours = currentTime.getHours();
    	var minutes = currentTime.getMinutes();
    
    	if (minutes < 10){
    	minutes = "0" + minutes
    	}
    	this.time = (hours + ":" + minutes + " ")
    	this.OUTtime = (hours + ":" + minutes + " ")
    	if(hours > 11){
    	night = ("PM")
    	} else {
    	morning = ("AM")
    	}
    	this.controller.get('divIdOuttime').update(this.time);
    	this.controller.get('divIdtime').update(this.OUTtime);
    };

    first-scene.html
    Code:
    <div id="main" class="palm-hasheader">
    	<div class="palm-header">Time Card Report</div>
    	<div id="text" class="palm-body-text">Today's date:</div>
    
    	<div id="divIdcount" class="palm-body-text" align="center">Shows the date</div>
    	<!-- when the user presses the CLOCK IN or OUT button the time of day is displayed
    	in the appropriate div But what's happening is when the user presses either button it updates BOTH divs-->
    
    	<div id="divIdtime" class="palm-body-text" align="center"></div>
    	<div id="divIdOuttime" class="palm-body-text" align="center"></div>
    
    	<div id="IN" name="InButton" x-mojo-element="Button"></div>
    	<div id="OUT" name="OutButton" x-mojo-element="Button"></div>
    </div>
  2. #2  
    i think it is because you have both buttons using the same this.handleButtonPress function. make a separate this.handleOutButtonPress function that only update the OUTtime.

    and because you do this:

    Code:
    	this.controller.get('divIdOuttime').update(this.time);
    	this.controller.get('divIdtime').update(this.OUTtime);
  3.    #3  
    Thank you that worked!

Posting Permissions