Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780

HTML5/Javascript onChange() not being called

<label for="frmAllegation-TimeReported">Reported Time</label>
<input type="time" name="Reported Time" id="frmAllegation-TimeReported" onchange="changeSave(this);" /><br>

<label for="frmAllegation-IncinOccDate">Date Started</label>
<input type="date" name="Reporting Date" id="frmAllegation-IncinOccDate" onchange="changeSave(this);" /><br>

 

<label for="frmAllegation-IncinOccText">Date Text</label> 
<input type="text" name="Reporting Text" id="frmAllegation-IncinOccText" onchange="changeSave(this);" /><br>

 

function changeSave(frmInput)

{

alert("Changed");

}

 

When using time,date,select  on change isnt called, Its strange because if you type stuff in its called but when blakcberry native date,time or option list pops up and you it pritns it to the form but doesnt call on save...

 

Work arounds or solutions anyone?

 

Thanks for support :smileyhappy:

Please use plain text.
Developer
nunodonato
Posts: 313
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha

Re: HTML5/Javascript onChange() not being called

Is that on the PlayBook or on phones?

I had that problem on the playbook with a date field, managed to workaround it using onBlur instead of onChange :smileywink:

Nuno
theBBthing.wordpress.com - my BlackBerry development blog: news, tips and tutorials
bitoutsidethebox.com - re-imagining digital solutions


Please use plain text.
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780

Re: HTML5/Javascript onChange() not being called

Its smartphone, does on blur has the same effect? e.g.

I only want to call my function if the data has been changed so i can edit my JSON...
Please use plain text.
Developer
nunodonato
Posts: 313
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha

Re: HTML5/Javascript onChange() not being called

Didn't try it on the phone, sorry.

Although if it does work, it will call the function even if the data doesn't change. If the code is very performance-intensive, you can add your own manual check before running it.

Nuno
theBBthing.wordpress.com - my BlackBerry development blog: news, tips and tutorials
bitoutsidethebox.com - re-imagining digital solutions


Please use plain text.
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780

Re: HTML5/Javascript onChange() not being called

If its any help to any reading this,

Ive done the following

On focus in save form value to temp varible
On focus out compare new value if temp
If its different then save new variable to JSON
If not then nothing

Basicly my own onchange function using the focus items...
Please use plain text.
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780

Re: HTML5/Javascript onChange() not being called

Also the official bug tracker is here: https://github.com/blackberry/WebWorks/issues/122
Please use plain text.
Developer
nunodonato
Posts: 313
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha

Re: HTML5/Javascript onChange() not being called

If you are just saving a variable, does it hurt to save it again even if it didn't change?

Not sure which of the ways runs more code :smileysurprised:)

Nuno
theBBthing.wordpress.com - my BlackBerry development blog: news, tips and tutorials
bitoutsidethebox.com - re-imagining digital solutions


Please use plain text.
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780

Re: HTML5/Javascript onChange() not being called

I agree to disagree with you on this one,

Because i am building my JSON dynamicallyi only include form fields that have a value, so saving it if it doesn't change would result in something like
var json {feild1: ""}

If you follow what im saying? What your saying would be good if i was building it dynamically.
Please use plain text.
Developer
nunodonato
Posts: 313
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha

Re: HTML5/Javascript onChange() not being called

[ Edited ]

So what if it has a value and the user changes it by deleting it?

won't it save the "" anyway? :smileyhappy:

I guess that requires an extra check then...

Nuno
theBBthing.wordpress.com - my BlackBerry development blog: news, tips and tutorials
bitoutsidethebox.com - re-imagining digital solutions


Please use plain text.
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780

Re: HTML5/Javascript onChange() not being called

Thanks for pointing that out exactly, Very good point will just require a small if statement... Have you done any development on smartphone or anything with a trackpad?
Please use plain text.