Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-30-2013, 07:00 PM   PM User | #1
johnsmith153
New Coder

 
Join Date: Mar 2012
Posts: 81
Thanks: 7
Thanked 0 Times in 0 Posts
johnsmith153 is infamous around these parts
Events not always firing

I'm not really sure how to go with this, but here goes:

I have form elements that trigger a function (mainly for validation purposes). This triggers on click, on change etc. These are written with vanilla JavaScript.

If it's a straight-forward HTML element then everything works fine. E.g. a <select> element fires on change.

However, if I use a jQuery script (e.g. a jQuery colour selector), then although that jQuery script populates an <input> field, the validation script doesn't fire.

This I suppose is obvious as you don't click, blur, change it, it's just the jQuery script changing it.

Of course I could change the JavaScript in the colour selector jQuery script so it also fires the validation script, but there must be a better way where as well as on click, on change, on blue etc. I can also activate the function when it picks up that another script is changing it. I need this for various occasions and scripts.

Another example is a rating script (rate out of 5). It uses radio buttons as a non-jQuery fallback and the jQuery script just hides those radios (with CSS), displays the star images and then changes the radios when the user interacts with the star images. That way the server handles a form submit the same way regardless of the availability of jQuery. However, the validation script doesn't fire.

Any ideas?
johnsmith153 is offline   Reply With Quote
Old 01-31-2013, 03:23 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,364
Thanks: 18
Thanked 347 Times in 346 Posts
sunfighter is on a distinguished road
Code makes everything a lot easier. Jquery needs a trigger just like form element validation. Why not just add the JQ in the validation function? I really don't think you need to use jq just to change the back ground color of an element, but I'm guessing without your code. Please post it.
sunfighter is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:19 PM.


Advertisement
Log in to turn off these ads.