e.model.isNew()

3 posts, 1 answers
  1. Answer
    Elliott
    Elliott avatar
    5 posts
    Member since:
    Oct 2013

    Posted 29 Oct 2013 Link to this post

    Hi,

    I am using the e.model.isNew() to change the Title of the popup depending on whether Edit or Save is pressed.
    That's working fine, I am however having an issue with then pressing the edit button to the added item.
    The pop up is shown but with "Add", not "Edit" as the title.

    If I refresh the page then it works as expected.

    Code:
    function onEdit(e) {
            if (e.model.isNew()) {
                // add
                $(".k-window-title").text("Add");
            } else {
                // edit
                $(".k-window-title").text("Edit");
            }

        }

    Is there a way on the save event to specify that the model is no longer new?

        function onSave(e) {
            // set the model no longer as new ??
            
        }
  2. nikobellic
    nikobellic avatar
    46 posts
    Member since:
    Feb 2013

    Posted 29 Oct 2013 Link to this post

    The isNew method returns true or false depending on the id value of that model. (docs)
    If the id is still set to the default value then it will assume it is a New Model.

    Are you doing something (probably backend side) to save this item into a database? that will usually auto-generate an id, so you can use that to assign to your client side js model.


    Hope that helps.
  3. Kendo UI is VS 2017 Ready
  4. Elliott
    Elliott avatar
    5 posts
    Member since:
    Oct 2013

    Posted 29 Oct 2013 Link to this post

    Worked like a charm.

    Thanks!
Back to Top