logo
down
shadow

Keep the the alert box without dismiss if there is an error


Keep the the alert box without dismiss if there is an error

By : user2185462
Date : November 21 2020, 04:01 AM
it helps some times return false is not the actual problem. You are calling alert.dismiss, that's the issue. If you don't want to hide alert, you should move dismiss code inside else block.
Please change your code to following
code :
 const allApiKeys = await this.apiKeySqliteProvider.getAllApiKeys();
                const alert = this.alertCtrl.create();
                alert.setTitle('Select Api Key');
                forEach(allApiKeys, (apiKey: ApiKey) => {
                  alert.addInput({
                    type: 'radio',
                    label: apiKey.name,
                    value: apiKey.key,
                    checked: false
                  });
                });
                alert.addButton({
                  text: 'Cancel',
                  role: 'cancel',
                  handler: data => {
                    this.loading.dismissLoader(loading);
                  }
                });
                alert.addButton({
                  text: 'OK',
                  handler: data => {
                      if (data == null) {
                        this.showToastProvider.showErrorToast("Invalid API Key");
                        this.loading.dismissLoader(loading);
                        return false;
                      }

                      // you don't need else here as by default it will hide alert
                  }
                });
                alert.present();
              } 


Share : facebook icon twitter icon
How can dismiss this alert dialog?

How can dismiss this alert dialog?


By : Max Lefarov
Date : March 29 2020, 07:55 AM
hope this fix your issue I don't know where you have written your code to launch the dialog. I have replicated your code. And this works as expected.
code :
public class MainActivity extends AppCompatActivity {

    private AlertDialog b;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // custom dialog
        AlertDialog.Builder dialogBuilder = new
                AlertDialog.Builder(this);
        LayoutInflater inflater = getLayoutInflater();
        final View dialogView = inflater.inflate(R.layout.custom_dialog, null);
        dialogBuilder.setView(dialogView);

        Button reject = (Button) dialogView.findViewById(R.id.reject_btn);
        Button accept = (Button) dialogView.findViewById(R.id.accept_btn);

        b = dialogBuilder.create();
        b.show();


        accept.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                b.dismiss();
            }
        });

        reject.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                b.dismiss();
            }
        });
    }
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <Button
        android:layout_width="wrap_content"
        android:id="@+id/reject_btn"
        android:text="Reject"
        android:layout_height="wrap_content" />
    <Button
        android:layout_width="wrap_content"
        android:id="@+id/accept_btn"
        android:text="Accept"
        android:layout_height="wrap_content" />
</LinearLayout>
Dismiss old alert and present latest alert - Ionic3

Dismiss old alert and present latest alert - Ionic3


By : Vasav
Date : March 29 2020, 07:55 AM
wish helps you I am using the alerts of Ionic 3 and I am facing an issue of alerts stacking up. I am using the network plugin to check if the user is connected to a network(WiFi/2G/3G etc.) or not and the idea is to trigger an alert every time the user goes offline or comes online.
code :
isAvailable: Boolean; //boolean variable helps to find which alert we should dissmiss   
connectedToInternet; //made global to get access 
noInternetAlert; // made global to get access


 this.connectSubscription = this.network.onConnect().subscribe(() => {
      console.log('network connected!');

      if(!this.isAvailable){ //checking if it is false then dismiss() the no internet alert
        this.noInternetAlert.dismiss();
      }
       this.isAvailable =true;

      this.connectedToInternet = this.alertController.create({
        subTitle: 'Connected to Internet',
        buttons: ['OK']
      });
      this.connectedToInternet.present();
    });

    this.disconnectSubscription = this.network.onDisconnect().subscribe(() => {

     if(this.isAvailable){// if it is true then dismiss the connected to internet alert
        this.connectedToInternet.dismiss();
      }
      this.isAvailable = false;
      this.noInternetAlert = this.alertController.create({
        subTitle: 'No Internet Connection. Please enable Wifi or Mobile data to continue.',
        buttons: ['OK']
      });
      this.noInternetAlert.present();
    });
dismiss bootstrap alert in Angular 2+ by clicking outside of alert

dismiss bootstrap alert in Angular 2+ by clicking outside of alert


By : mohammed ebrahim
Date : March 29 2020, 07:55 AM
Any of those help One of the way to approach this problem would be creating additional "overlay" element, that would basically lay just below the modal in the DOM. Your html should look somewhere like:
code :
<div class="overlay" (click)="this.MiddleC = false"></div>
<div class="alert alert-primary alert-dismissible fade show" role="alert" *ngIf="this.MiddleC == true">
  <strong>YES!!! That's Middle C!!!</strong>
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>
.overlay{
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: MODAL_ZINDEX - 1;
}
@HostListener('window:click', ['$event'])
onWindowClick($event){
  //check if its not modal that is clicked
}
Why attempting to dismiss UIAlertController too early does not dismiss the Alert

Why attempting to dismiss UIAlertController too early does not dismiss the Alert


By : Tianirika
Date : March 29 2020, 07:55 AM
it helps some times Because, as long as you pass animated: true, the alert controller will not be in the hierarchy until it is done animating, so you can't dismiss it until then. This is precisely what the completion block is used for (generally, any good API where things happen asynchronously will provide you a completion block to let you know when that action is complete). You can dismiss immediately after presenting (though I don't imagine this is a valuable real-life use case) by doing:
code :
present(alertController, animated: true, completion: { 
    alertController.dismiss(animated: true, completion: nil)
})
How to dismiss other Alert Controller and present a new Alert Controller immediately without delay

How to dismiss other Alert Controller and present a new Alert Controller immediately without delay


By : Coreman
Date : March 29 2020, 07:55 AM
should help you out I see a couple of potential issues in your code, try to change these:
code :
DispatchQueue.main.async {
  NotificationCenter.default.post(name: NSNotification.Name(rawValue: "StayAsMaster"), object: nil, userInfo: [peerID:dict.first!])
}
deinit {
  NotificationCenter.default.removeObserver(self)
}
Related Posts Related Posts :
  • ERROR TypeError: (intermediate value).share is not a function
  • angular 4 typescript validation error Object literal may only specify known properties
  • Angular, using one component in other two components
  • ngx-select-dropdown -- how to set default value for the dropdown? (angular 6.x)
  • Angular - reference child component dynamically
  • RXJS - Filter appears to filter, but results still show unfiltered
  • How to make changes on value which came with @Input - Angular
  • QR Scan in Angular
  • Angular / API consuming - request header - CORS proxy
  • Ng If does not work in observable variable in Angular 6
  • Angular Material 7: Link for whole row
  • How to customize PrimeNG TurboTable paginator?
  • ExpressionChangedAfterItHasBeenCheckedError when using ReactiveForms and NgbModal
  • Angular Material table with right-to-left direction
  • Angular 7 how to calculate the time a component take to completely load on the DOM
  • Observerable appending data over and over again on populate action
  • this is not a function - Angular 5
  • angular app runs in local tomcat but gives error in dev environment
  • Angular: Pass data from Material Dialog to component, which didn't open the dialog
  • Textarea typing issue in ngFor in Angular 6
  • fxFlex angular flex layout not working as expected version 7.0.0-beta.19
  • Combine requests in series - Angular 7
  • Display table for dyanamically created row in angular 5
  • ngFor does not render my obersavle response, but it does inset old values I add to the array?
  • Concat variable name in angular cli using ngFor
  • Angular 5 'inputClick' is declared but its value is never read
  • Angular 7 - getting error as `Module parse failed: Unexpected character '@'` how to fix this?
  • RxJs subscribeTo.js observable check works in Chrome, but fails in Chrome Incognito, MS Edge, and Firefox
  • Getting the error: Could not find column with id "id"
  • Angular 5 - Dynamic base reference is causing duplicate loading of bundles|chunks
  • Angular - use a service in a function and this function in a pipe
  • How to dynamically call the parent methods from child component?
  • Trigger same function in different component
  • Angular 7 error RangeError: Maximum call stack size exceeded
  • Maximum call stack size exceeded when adding PWA in Angular
  • angular reactive forms remove formArray elements after save
  • check whether angular array object has a specified value or not
  • While using moment in Angular 7 getting Error:TypeError: moment is not a function
  • Cannot set property 'filterPredicate' of undefined error in Angular Material Table
  • Angular 2+ Animation: Adding checkbox check effect to individual checkboxes that are generated by a loop
  • I am having issue in checking whether a username exists or not in my angular 6 application via api
  • How can I convert an ionic http GET request from @angular\Http to @ion-native\Http?
  • fa-icon is not a known element in a Reusable Module
  • Angular 6: Is it possible to pass a function as parameter?
  • Angular Reactive Forms with FormArray inside a nested FormGroup
  • Angular: Right way to wait for Async data to be loaded
  • NgRX effect called with empty state
  • How do you create a union type for a component's services?
  • Angular6 - Using service outside of constructor - error as undefined
  • How to import a service from another module in Angular 6
  • Fetch Wordpress API data into Angular 7
  • AngularMaterial - MatRipple is displaying ripple outside table row
  • How to change child component style with Emulated encapsulation in Angular 6?
  • Angular 7 service not acting as a singleton
  • Wrong date from java GET
  • Angular PrimeNg- Callback on SideNav close
  • Angular use $event.target or ViewChild...is there a difference?
  • Weird update behavior: Template constantly calls display function
  • Confused about typescript scopes
  • When dealing with NgRx, why use Typescript Getter to display properties on templates?
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org