Search code examples
javascriptjquerybackbone.jshandlebars.jsbackbone-forms

On double click to an icon, popup and back screen both are getting faded


We are using backbone dynamic forms.I have a textfield, on click to that field, a pop up opens up. This is my functionality.

But on double click to that field screen getting faded and no way to get back. Again new window has to be opened for working.

The solution has to support any browser mainly Chrome, Firefox, IE


Solution

  • Using a count variable we can resolve this. Just follow the below steps:
    1. Initialise the count variable to 0.
    2. If count is 0, then only trigger the lookup event
    3. Make the count variable to 1 on click to field, which triggers event to show lookup
    4. On close to lookup panel again make the count to 0.

    Sample code:

    ## MainFormView.js ##
    count:0, 
    initialize: function (options) {this.count = 0;},
    events: {
        'click #lookupId': 'showLookup'
    },
    showLookup: function (e) {
        e.stopPropagation();
        if(this.count == 0){
            this.count = 1;
            this.trigger("show:list");
        }
    }
    
    ### LookupView.js ###
    lookupView: null,
    initialize: function (options) {
        this.lookupView= options.renderedFormView;
    },
    closePanel: function() {
        this.lookupView.count = 0;
    }
    
    ## MainController.js ##
    mainFormView.on("show:list", function () {
        var lookupView = new LookupView({
            model: staffList,
            renderedFormView: mainFormView
        });
    });