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

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

Related

Set option selection on mat-select to return placeholder after selection

I have the following Angular 6 code:
https://stackblitz.com/edit/angular-pl9wkw
I'm tryin g to make the select dropdown reset to the place holder once a selection has been made. I am using these two lines to try and reference the process:
#ViewChild('selectDropdown') selectDropdown: MatSelect;
and
this.selectDropdown.AppComponent.reset();
Alas, it does not work to set the dropdown back to the placeholder. I know that it can be set back to the placeholder, because I have the blank <mat-option></mat-option> selectable, and once you do select it, it sets it back to the placeholder.
Any thoughts ... anyone.
In your onChange method make the following change.
this.selectDropdown.value = [];
// this.selectDropdown.AppComponent.reset();
In your Onchange make following change
this.selectDropdown.value.reset();

How to Trigger keyup event on Dojo?

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();

Interacting with VB6 client using hidden control in embedded web browser control

I'm having difficulty trapping a programmatically triggered click event on a hidden button control from a ASP.NET MVC 4 web app inside a VB6 thick client (which is using a web browser control). I'm able to trap the click event itself using the following:
Private WithEvents WebDoc As HTMLDocument
Private Function WebDoc_onclick() As Boolean
Select Case WebDoc.activeElement.iD
Case "A"
Do something
Case "C"
Do something else
End Select
WebDoc_onclick = True
End Function
And this works just fine if the control is visible. But if the control is invisible:
<div class="HideBtnDiv">
<input id="C" name="NoItems" type="button" class="BtnDiv" style="display:none"/>
</div>
and I try to trigger a programmatic click via one of the following:
$("#C").('click');
$("#C").trigger('click');
$("#C").triggerhandler("click");
$("#C").focus();
$("#C").trigger('click');
I'm getting an empty string for the "id" attribute and as a result I can't distinguish which button was clicked. This button serves no purpose other than to indicate to the VB6 app that a certain criteria has been met and that's the reason why I need it to be hidden. Does anyone have any idea why the id is getting stripped? Or is there any other way to communicate back to the client?
I've also tried filtering by element style using
Select Case WebDoc.activeElement.Style
Case "display:none"
Do something else
End Select
but it came back as "[Object]" so no luck there either. Please let me know if there is a way around this.
Thanks,
Lijin
You seem to have tried several ways of dynamically triggering the click event, but did you try the most obvious way:
$("#C").click();
???
But here is what I would do:
1- Make all of your buttons visible, by removing "display:none" from their style
2- Wrap the buttons you want to hide in a new DIV
3- Set "display:none" style in the newly created DIV
4- You can then trigger the .click() event of any button even if not visible by calling $(id).click();
Thanks, Ahmad. Actually I meant .click() not .('click'). Sorry about that.
Anyway, I tried your suggestion and made the button visible and set the style of the wrapping div to display:none but the id attribute was still coming through as an empty string.
However, I did figure out another way to get this to work. If I keep the wrapping div and button as visible and then focus and click when the condition is met and then do a hide(), my problem is resolved!
$("#C").focus();
$("#C").trigger('click');
$("#C").hide();
The button doesn't get displayed and VB6 still passes the id on the click event. The weird thing is it requires the focus() call to still be made. Without it, I'm back to square one. Not sure if this is a bug.

How can I update Yii's CListView when a new record was added triggered by an AJAX call?

Yesterday I was introduced to the CListView and could manage to display all the information i want about my records, and in the format i want. I have a 'create' button (add a new contact), which opens a modal pop up window with the corresponding fields. When this window is closed, i return to the CListView, and here is my issue: i've been trying to update the CListView (without any luck, clearly).
I believe it should be easy to update the clistview with this call: $.fn.yiiListView.update('CListViews's ID'), but i can't find the proper event that should trigger this call.
Next, i post what i would think is the relevant code:
Button
echo CHtml::ajaxButton ("Create",
CController::createUrl('/contacts/create'),
array('onclick'=>'
$("#createContact").dialog("open");
return false;',
'update'=>'#createContact'),
array('id'=>'showCreateContactDialog'));?>
CListView
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>new CArrayDataProvider($model->contacts, array('pagination'=>array('pageSize'=>5,),)),
'itemView'=>'_view',
'emptyText'=>'empty',
'template'=>"{items}\n{pager}",
'pagerCssClass'=>'page-number',
'id'=>'ajaxListView',
));?>
Any help is more than welcome!! Hope this helps someone eventually as well.
If I understand correctly, your problem is finding what to trigger the CListView update with (the JS update snippet you provide should work fine).
Probably the jQuery dialog event close is what you are looking for; it will get triggered after the dialog has been closed. Alternatively, there is also a beforeClose event that has the additional capability to prevent the dialog from closing.

jQuery Showing an Ajax loader during transmission & Prevent Multiple Submits

I have an app that has several different types of form elements which all post data to the server with jQuery AJAX.
What I want to do is:
Show a loader during AJAX transmission
Prevent the user from submitting twice+ (clicking a lot)
This is easy to do on a one off basis for every type of form on the site (comments, file upload, etc). But I'm curious to learn if that is a more global way to handle this?
Something that's smart enough to say:
If a form is submitting to the server and waiting for a response, ignore all submits
Show a DISABLED class on the submitted / clicked item
Show a loading class on the class="spinner" which is closest to the submit item clicked
What do you think? Good idea? Done before?
Take a look at the jQuery Global Ajax Event Handlers.
In a nutshell, you can set events which occur on each and every AJAX request, hence the name Global Event Handlers. There are a few different events, I'll use ajaxStart() and ajaxComplete() in my code sample below.
The idea is that we show the loading, disable the form & button on the ajaxStart() event, then reenable the form and hide the loading element inside the ajaxComplete() event.
var $form = $("form");
$form.ajaxStart(function() {
// show loading
$("#loading", this).show();
// Add class of disabled to form element
$(this).addClass("disabled");
// Disable button
$("input[type=submit]", this).attr("disabled", true);
});
And the AJAX complete event
$form.ajaxComplete(function() {
// hide loading
$("#loading", this).hide();
// Remove disabled class
$(this).removeClass("disabled");
// Re-enable button
$("input[type=submit]", this).removeAttr("disabled");
});
You might need to attach to the ajaxError event as well in case an AJAX call fails since you might need to clean up some of the elements. Test it out and see what happens on a failed AJAX request.
P.S. If you're calling $.ajax or similar ($.getJSON), you can still set these events via $.ajaxStart and $.ajaxComplete since the AJAX isn't attached to any element. You'll need to rearrange the code a little though since you won't have access to $(this).
I believe you have to do 2 for sure and 3 to improve usability of your app. It is better to keep backend dumb but if you have a security issue you should handle that too.

Resources