[how to] Keeping a reference of the current model

13 views
Skip to first unread message

Mihnea Dobrescu-Balaur

unread,
Apr 7, 2014, 1:44:49 PM4/7/14
to cozy-...@googlegroups.com
Hello,

I was trying to get the following to work in cozy-files:

* click on an operations link (like rename file)
* in the handler for the link, display a modal dialog
* on the confirm handler for the dialog, do something with the file

I encountered a few problems:

1. I managed to bind the listener for the operation link in file.coffee, but I couldn’t bind the listener for the dialog confirm button
2. I could only bind the listener for the dialog confirm button in folder.coffee, but in that handler I didn’t have a proper @model that I could work with
3. I tried to save @model in a temp variable in file.coffee (in the operation link handler) and then access it from the handler in folder.coffee and that didn’t work either

How am I supposed to do this?


Thanks!
--
Mihnea Dobrescu-Balaur

Romain Foucault

unread,
Apr 8, 2014, 3:43:10 AM4/8/14
to cozy-...@googlegroups.com
Hi Mihnea, 

You can use the ModalView we have in cozy-files.



Mihnea Dobrescu-Balaur

unread,
Apr 8, 2014, 4:01:33 AM4/8/14
to Romain Foucault, cozy-...@googlegroups.com
I see, thanks. And if I want my modal to include a text input? Should I make a new template?

(I want to make the user input part for adding a new tag in https://github.com/mycozycloud/cozy-files/pull/26 )


Thanks,
--
Mihnea Dobrescu-Balaur

------------------------------------------------------
From: Romain Foucault romain....@cozycloud.cc
Reply: cozy-...@googlegroups.com cozy-...@googlegroups.com
Date: 8 Apr 2014 at 09:43:34
To: cozy-...@googlegroups.com cozy-...@googlegroups.com
Subject:  Re: [how to] Keeping a reference of the current model

Romain Foucault

unread,
Apr 8, 2014, 4:28:14 AM4/8/14
to Mihnea Dobrescu-Balaur, cozy-...@googlegroups.com
You can extend the ModalView, with something like that : 

module.exports = class InputModal extends ModalView

    onYes: ->
        @cb @$('#modal-input').val() if @cb
        @cb = null
        super

    render: ->
        super
        @$('#modal-dialog .modal-boby').append $('<input type="text" id="modal-input">')
        return this


Alternatively, consider using the tag-it jquery plugin (http://aehlke.github.io/tag-it/) for inline tag editing.


Mihnea Dobrescu-Balaur

unread,
Apr 8, 2014, 6:25:08 AM4/8/14
to Romain Foucault, cozy-...@googlegroups.com
Oh I didn’t know about the tags functionality in the contacts app. That’s what I need. I’ll try to reuse the code from that view, thanks.

--
Mihnea Dobrescu-Balaur

------------------------------------------------------
From: Romain Foucault romain....@cozycloud.cc
Reply: Romain Foucault romain....@cozycloud.cc
Date: 8 Apr 2014 at 10:28:37
To: Mihnea Dobrescu-Balaur mih...@linux.com
Cc: cozy-...@googlegroups.com cozy-...@googlegroups.com
Subject:  Re: [how to] Keeping a reference of the current model

> You can extend the ModalView, with something like that :
>
> module.exports = class InputModal extends ModalView
>
> onYes: ->
> @cb @$('#modal-input').val() if @cb
> @cb = null
> super
>
> render: ->
> super
> @$('#modal-dialog .modal-boby').append $('> id="modal-input">')
Reply all
Reply to author
Forward
0 new messages