Home › Forums › Cascading dropdowns › trigger function on spjs.casc.add
- This topic has 5 replies, 2 voices, and was last updated 4 years, 7 months ago by Alexander Bautz.
-
AuthorPosts
-
-
April 28, 2020 at 23:05 #29687
Hi,
I’m using the cascading dropdowns multi item functionality and I want to trigger a custom function when items are added.
I see spjs.casc.add(“internalFieldName,internalFieldName,0) in the console for the add button. How to use this to trigger my function on each add or remove?
-
April 29, 2020 at 15:32 #29720
I haven’t built in any “hooks” you can use, but by just adding something like this to your custom js you can pick up all changes:
jQuery("#dffs_LOB").find('input:text,textarea').on("change", function(){ console.log(jQuery(this).val()); });
In this example the field internal name is LOB so you must replace that with your field internal name.
Alexander
-
April 29, 2020 at 22:11 #29740
Thank you very much, Alexander! This worked for text field, but not the “select” drop down options for other fields.
Would you happen to know how I can trigger a change event for sharepoint dropdown columns? I tried the below, but it does not work.
jQuery(“dffs_FIELDNAMEHERE”).find(‘input”select’).on(“change”, function(){
//my code
}); -
April 30, 2020 at 15:57 #29747
You must use this format to get the value of a normal dropdown (the value in the casc-dropdown is stored in a text field or textarea hidden behind the controls):
jQuery("#dffs_YOUR_FIELD_NAME").find("select").on("change", function(){ var opt = jQuery(this).find("option:selected"); var id = opt.val(); var txt = opt.text(); console.log(id+":"+txt); });
Alexander
-
April 30, 2020 at 17:03 #29756
Thank you, Alexander.
I’m using jQuery UI with DFFS. Any way to detect an on change event for a date field? My code will run when I type a date, but not when I use the jqueryUI date selector widget.
jQuery(“#dffs_Date1”).find(“input”).datepicker();
-
April 30, 2020 at 18:12 #29758
You can use something like this:
var currentDateFieldValue = getFieldValue("Date1"); setInterval(function(){ var val = getFieldValue("Date1"); if(val !== currentDateFieldValue){ currentDateFieldValue = val; // trigger your code here } },500);
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.