javascript - Close modal which has been created in another event function -


on first event open mbox dialog. mbox kind of extention bootbox, showing modal. need mbox use template modal content.

so in modal loaded content of createelement-template. if user has done input changes modal should closed. therefore there function modal("hide"). bbox been set in first template-event , closing of modal done in second template-event, got problems close modal.

events

template.main.events({     'submit form': function(event, template) {         event.preventdefault();          var bbox = mbox.dialog({             title: 'title',             message: template.createelement         });     } });  template.createelement.events({     'change input': function(event, template) {         bbox.modal('hide');     } }); 

update

the above problem works global var. adam that.

but not destroy modal in meteor package, created package. tried use global var , tried use api.export(). still doesn't work. tried work sessions.

package-graph/lib/client/graph.js

var bbox; canvasmanager = {     onshowaddtooltip (element) {         bbox = mbox.dialog({ // <-- create modal             title: "title",             message: template.search, // <-- loading template search 1 input field typeahead         });     }, }  canvasmanger.create(...); 

package-graph/lib/package.js

api.export('bbox'); 

the second package provide typeahead-searchbox (sergeyt:typeahead). creating modal in first package, template loaded in modal (helloludger:mbox). user can search via typeahead , select item. after selection modal should destroyed `modal('hide').

package-search/lib/client/events.js

template.searchmain.onrendered(function() {     meteor.typeahead.inject(); }); 

package-search/lib/client/helper.js

template.search.helpers({ // <-- getting data input typeahead     searchdata: function() {         return [             {                 name: 'cat1',                 valuekey: 'title',                 displaykey: 'title',                 header: '<h3 class="category-name">category</h3>',                 template: 'searchresults',                 local: function() {                     return collection.find().fetch();                 }             }         ]     },     selected: function(event, suggestion) { // <-- selecting item, can process data , remove modal             //             bbox.modal('hide'); // <!-- destroy modal             return;         }     } }); 

make bbox global variable:

var bbox; template.main.events({     'submit form': function(event, template) {         event.preventdefault();          bbox = mbox.dialog({             title: 'title',             message: template.createelement         });     } });  template.createelement.events({     'change input': function(event, template) {         bbox && bbox.modal('hide');     } }); 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -