Fix mentioning model being broken when reopening it

This commit is contained in:
Steffen van Bergerem 2016-08-10 23:09:49 +02:00
parent 049b607b35
commit d60862c3c6
No known key found for this signature in database
GPG key ID: 2F08F75F9525C7E0
3 changed files with 24 additions and 14 deletions

View file

@ -7,6 +7,7 @@
modalBody.load(url, function(){
$(id).find("#modalWaiter").remove();
$(id).trigger("modal:loaded");
});
};
})();

View file

@ -15,6 +15,8 @@ app.views.ProfileHeader = app.views.Base.extend({
initialize: function(opts) {
this.photos = _.has(opts, 'photos') ? opts.photos : null;
this.contacts = _.has(opts, 'contacts') ? opts.contacts : null;
$("#mentionModal").on("modal:loaded", this.mentionModalLoaded.bind(this));
$("#mentionModal").on("hidden.bs.modal", this.mentionModalHidden);
},
presenter: function() {
@ -52,10 +54,30 @@ app.views.ProfileHeader = app.views.Base.extend({
return (this.contacts && this.contacts > 0);
},
showMentionModal: function(){
showMentionModal: function() {
app.helpers.showModal("#mentionModal");
},
mentionModalLoaded: function() {
app.publisher = new app.views.Publisher({
standalone: true,
prefillMention: _.extend({handle: this.model.get("diaspora_id")}, this.model.attributes)
});
app.publisher.open();
$("#publisher").bind("ajax:success", function() {
$("#mentionModal").modal("hide");
app.publisher.clear();
app.publisher.remove();
location.reload();
});
},
mentionModalHidden: function() {
app.publisher.clear();
app.publisher.remove();
$("#mentionModal .modal-body").empty();
},
showMessageModal: function(){
app.helpers.showModal("#conversationModal");
},

View file

@ -4,16 +4,3 @@
:selected_aspects => @aspects_with_person,
:person => @person }
:javascript
$(function() {
app.publisher = new app.views.Publisher({
standalone: true,
prefillMention: #{json_escape @person.to_json}
});
app.publisher.open();
$("#publisher").bind('ajax:success', function(){
$("#mentionModal").modal('hide');
app.publisher.clear();
location.reload();
});
});