call a function with BootStrap DateTimePicker(2)

call a function with BootStrap DateTimePicker(2)

Rob BrunRob Brun Posts: 56Questions: 2Answers: 14
edited April 2017 in Free community support

Hi, I am trying to clear the date Fields in my editor before the create form is displayed. I am using the BootStrap DateTimePicker(2) plugin. I have been trying different variations of this

 editor.on('initCreate', function (e) {
       editor.field('HireDate').clear();
});

Or

editor.on('initCreate', function (e) {
       editor.field('HireDate').val("");
});

So far unsuccessful, I am hoping someone can point me in the right direction.

This question has an accepted answers - jump to answer

Answers

  • Rob BrunRob Brun Posts: 56Questions: 2Answers: 14
    edited April 2017 Answer ✓

    Ok, I figured out a solution to my situation. I was hoping I could just clear the text field some how, but what I ended up having to do is eliminate the field from the editor and then add it back using the clear method and then the add method for the editor.

     editor.on('initCreate', function (e) {
                       
                        
                        editor.clear('HireDate');
                     
                        editor.add({
                            type: "datetime",
                            label: "Hire Date:",
                            name: "HireDate",
    
                            "opts": {
    
                                format: "YYYYMMDD"
                            }
    
                        });
                     
                    });
    
    
  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin

    editor.field('HireDate').val("");

    I'm surprised that option didn't work. Although perhaps the Bootstrap date time picker doesn't allow for that.

    Allan

  • Rob BrunRob Brun Posts: 56Questions: 2Answers: 14
    edited April 2017

    Hi Allen, The behavior I was getting was the values inside of the Date fields would stick after the editor closed. So when I would go to create a new record after an edit the values from the edit would still be in the date fields. This would only happen for the date fields, the rest of the fields clear on their own like normal. It would also only happen on a create, an edit would replace the value with the value from the record that was being edited.

    I was thinking that maybe I had to use the clear() method for the DateTimePicker, I didn't know how to call it though.

This discussion has been closed.