Coder Social home page Coder Social logo

Comments (6)

vorko avatar vorko commented on August 22, 2024

i also try to use opened promise... but when it's fired, dialog is not ready...

dlg = $dialogs.create('views/dialogs/rest_newbonuses.html', 'RestNewbonusesCtrl', {}, {
      key : false,
      back : 'static'
    });

  dlg.opened.then(function() {

$('#select-model').selectize({
create : true,
sortField : 'text'
});
    console.log('coucou');
  });

nb : when i call selectize on the console when dialog is on the screen, it's working...

from angular-dialog-service.

m-e-conroy avatar m-e-conroy commented on August 22, 2024

The returned modal object that uses "opened" is a function of the Angular-UI-Bootstrap project, $dialogs.create only returns the created $modalInstance. I think if "opened" doesn't work it may be a question for the Angular-UI team. I'll take a look at it when I have time, but I have a feeling its more about the way your application is constructed. $viewContentLoaded is an event attached to ng-view, the modal will not respond to this event in the dialog's controller.

There are two things that I can think of right now that may be the problem.

  1. You have a race situation. The modal doesn't render before your init code gets executed. Try using a $timeout around your init function to see if that is the culprit - I'm not saying that this is a solution to the problem I'm suggesting this might help to narrow done whats actually happening.
  2. Your selectize script happens outside the scope of Angular and inside the scope of jQuery. You need to $apply changes made via jQuery to Angular's scope.

from angular-dialog-service.

m-e-conroy avatar m-e-conroy commented on August 22, 2024

Just read your little note about using selectize on the console when the dialog is on screen, to me this says you have the "race" situation. Your selectize code is executing prior to the modal being rendered.

from angular-dialog-service.

m-e-conroy avatar m-e-conroy commented on August 22, 2024

I ran a test using the "modal.opened.then" - the supplied function to "then" executes prior to the modal being rendered.

The Angular-UI docs state that the "opened" promise "is resolved when a modal gets opened after downloading content's template and resolving all variables" - this happens before the modal is rendered to the page.

I suggest trying to use the $timeout service to delay the execution of your init function.

from angular-dialog-service.

m-e-conroy avatar m-e-conroy commented on August 22, 2024

Any luck?

from angular-dialog-service.

vorko avatar vorko commented on August 22, 2024
$timeout(function(){init();}); 

and all is ok.... :-)

Thanks for your help

NB : i try to $apply but it does nothing.

from angular-dialog-service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.