How to Trigger keyup event on Dojo? - events

I'm using Dojo in my aplication that uses the Arcgis Map Api.
I need to set the value in the Input text (Geocoder, widget from the API) and trigger the keyup event so the autocomplete would works.
Anyone knows how to do that?

The easiest way is to fetch the event like this:
on(dom.byId("yourNodeName"), "keyup", callfunctionXY);
regards,Miriam

Assuming you want to set the Geocoder's text value programmatically and then trigger the Geocoder's auto-complete based on the value you set, this seems to work:
var thePlace = "42 Wallaby Way";
//var geocoder is of type esri/dijit/Geocoder
geocoder.value = thePlace;
geocoder.inputNode.value = thePlace;
geocoder._autoComplete();

Related

MDC web components - Deactivating focus from textfield not working

I am trying to implement an autocomplete input by using mdc web components. I have a menu selected event listener, where I want to deactivate focus on a textfield. I have tried that by using MDCTextFieldFoundation deactivateFocus method:
const inputFoundation = new MDCTextFieldFoundation(
document.querySelector(".mdc-text-field")
);
menu.listen("MDCMenu:selected", e => {
console.log(inputFoundation);
input.value = e.detail.item.dataset.value;
inputFoundation.deactivateFocus();
});
But, that is not working. In the console, I can also see that input's property isFocused is false, when textfield is still focused. You can see the whole codesandbox here. What am I doing wrong here and what is the correct way of deactivating focus from a textfield?
From docs:
Deactivates the focus state of the Text Field. Normally called in response to the input blur event.
So deactivateFocus updates the state of the component, but it doesn't change focus.
You need to call blur yourself. For example like this:
document.activeElement.blur()

Calculation from Value-List in Archer GRC based on date (with non-empty validation)

I've been trying to implement what's been asked in this Stack Overflow question, here:
Calculation for status in Archer GRC based on date
Trying to create a status field based on a number of Value Lists that
users select from, but a request has been made that we check a date
field for a value to ensure an estimated date has been set so that the
calculation can determine if the status of the record is "In
Progress", "Late" or "Not Started".
...and now, I have a requirement for an actual popup warning message of some sort to prompt the user to make sure the date field is not blank.
How would I add this functionality?
In order to deliver the functionality you are looking for you have to use a "Custom Object". It is an object you put on the layout of the application in Archer that contains JavaScript code. This code will be executed as soon as the form of the application is loaded. There is a special type of the field "Custom Object" available in the Layout editor for each application in the Application Builder in Archer.
Note - I don't recommend to use custom objects in general and neither RSA Support. Every time you modify the layout in the given application, you have retest and sometimes correct IDs for your custom object. You can write an ID independent custom object and use field names, but in this case custom object will have more code. I prefer to make custom objects as short as possible.
Your custom object should do the following:
Override the behavior of the "Save" and "Apply" button in the top tool bar available for every application form in Archer.
Once "Save" and "Apply" buttons are "overwritten", every time they are clicked on your function will be called. So you need to create a click handler function.
Your click handler function will check values user is required to populate and will either return warning, or will call the original handler for "Save/Apply" buttons.
This is a code template you can start with:
<script type="text/javascript">
// ids are used to locate buttons
var buttons_ids = [
"master_btnSave", // "Save" button ID
"master_btnApply" // "Apply" button ID
];
// parameters are used in the "onclick" default handlers to call original handlers
var buttons_parameters = [
"master$btnSave", // "Save" parameter
"master$btnApply" // "Apply" parameter
];
document.getElementById(buttons_ids[0]).onclick = function(){ Validator_of_required_fields(buttons_parameters[0])};
document.getElementById(buttons_ids[1]).onclick = function(){ Validator_of_required_fields(buttons_parameters[1])};
// end of the script body
//==== Validator function attached to Save and Apply buttons
function Validator_of_required_fields(parameter){
// ids of the input fields to validate
var inputs_to_validate_ip_address = [ "master_DefaultContent_rts_XXX_YYY_t" ];
// jQuery selector is used here. Archer v5.x has jQuery library loaded by default
// you will need to modify this selector
var field_value = $('#'+inputs_to_validate_ip_address[0]+':first').val();
if(field_value.length = 0) {
// Here you are calling Archer Warning function
var msg = "[Text to display to user]";
var title = 'Required Field';
WarningAlert(msg,title);
return false;
};
// default onclick processor
ShowAnimationAndPostback(parameter);
return false;
};
Some comments on this code:
You will need to modify the validation function to work with values stored in the fields you need.
I used a rather 'unusual' way to override the behavior of the "Save" and "Apply" buttons using the following code:
document.getElementById(buttons_ids[0]).onclick = function(){ bla, bla, bla }There are simpler way to do the same, but this way custom object works fine in IE8-11, FF, Chrome and Opera. Let me know if you find a simpler way to override buttons that is browser agnostic.
Function WarningAlert(msg,title); is a build-in Archer warning message function. It worked fine in Archer v5.4. You might need to use simple JavaScript Alert function if WarningAlert doesn't work in your version of Archer.
Note that behavior of the "Save" and "Apply" buttons might be overwritten back to default in case if user opens up any pop-up dialog windows to populate a value list or cross-reference field. If that is the case, you will have to wrap the code provided into another function and attach it to the OnLoadWindow event (or similar).
I try to avoid using any JavaScript libraries in my custom objects. This way it is simpler to support them and you have less dependencies. I used jQuery in the provided example only because Archer already uses this library once the page is loaded.
Flak, make sure to test your custom object very well and good luck!

Set value of numberfield without firing "change" event in Sencha Touch

I have a numberfield and a list in Sencha Touch. When I click on an item in the list, I am doing an AJAX request to send data to the server. However, if there is data in the numberfield, I want to clear that when the list is clicked on. I have no problem doing this (I am setting the value to a blank string), however, the change event is fired on the numberfield. This causes another AJAX request to run which doesn't need to. Is there any way to clear a numberfield WITHOUT firing the change event? SuspendEvents does not work as clearing the numberfield requires an event. Any thoughts or suggestions? Thanks!Code lines that I have tried: suspendEvents(); me.getWhatScreen().down('numberfield[name=caseNumber]').setValue(''); resumeEvents(true); me.suspendEvents(); me.getWhatScreen().down('numberfield[name=caseNumber]').setValue(''); me.resumeEvents(true);
Do suspendEvents(), update your numberfield and then do resumeEvents()
UPDATE
var control = me.getWhatScreen().down(...);
control.suspendEvents();
control.setValue('');
control.resumeEvents(false);
UPDATE for Sencha Touch 2.4
the correct sequence is
var control = me.getWhatScreen().down(...);
control.suspendEvents();
control.setValue('');
control.resumeEvents(true);
resumeEvents takes the boolean parameter discardQueuedEvents

How can I display another filed title, not an event title on a jQuery FullCalendar?

On the calendar I'd like to display another field title (like requestID#) along with a time reserved instead of the event title. I'm not sure where and how I need to make changes to the fullcalendar.js file. Thanks in advance for your help.
What eventsource are you using?
If you are building your own, you could just put requestID# in the title property on the event object.
Or you could put it in a custom field like: event.requestId and change the title in the eventRender callback like so:
eventRender: function (event, element) {
element.find('.fc-event-title').text(event.requesetId);
}

Disable Case Resolution Action on form load

I am trying to disable the ability to resolve a case in CRM unless a couple fields have data. I would like to gray out the case resolution action and was wondering if anyone knew how to do this on the form Load.
Thanks!
Try with this code on the OnLoad event of the Case form:
var menuItem = document.getElementById('_MIresolve');
if (menuItem)
menuItem.disabled = 1;
You can Ctrl+N any CRM page in order to be able to view its source code and figure out ids of controls.

Resources