Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

Subform not saving

Questions related to using nuBuilder Forte.
Locked
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Subform not saving

Unread post by tonyd »

I have a subform
subform.jpg
whose parent has the following code:

Code: Select all

if(nuFormType() == 'browse'){
    nuShowBrowseImages()
}else{
    nuShowFile();
}




function nuBeforeSave(){

    $('[data-nu-table="Docs"]').each(function(index,item){
        if (item.children[2].classList.contains("nuEdited")){

            var j = JSON.parse(item.children[2].value);
            var d = Date.now();

            item.children[5].value = j.name; //'File Name' column
            item.children[4].value = Date(d);//'Last Modified' column
            nuHasBeenEdited();
        }
    });
   

    return true;

}


function nuShowFile(){
   $('[data-nu-table="Docs"]').each(function(index){

        var t = $(this)[0].children;
        if (t[1].value !== '') {
            
            $.ajax({
                url: 'https://' + window.location.hostname + '/upload-target/' + t[5].value,
                method: 'GET',
                xhrFields: {
                    responseType: 'blob'
                },
                success: function (data) {
                    var ur = window.URL.createObjectURL(data);
                    var x   = document.createElement("EMBED");
                    var ty = data.type
                    x.setAttribute("type", ty);
                    x.setAttribute("src", ur);
                    x.setAttribute("width", "140px");
                    x.setAttribute("height", "140px");
                    
                    t[0].innerHTML = '';
                    t[0].appendChild(x);
                },
                error: function(data) {
                    alert("Failed to get file")
                }
            });
        }
   });
}


function nuShowBrowseImages(){
    //console.log($('[data-nu-column="0"]')[0].innerText);
}
As you can see, I have some code to set two of the column values if the file selection has been modified. The problem comes when I click the 'save' button on the parent form the values return to the original. I cannot seem to find where this would be fixed. I am sure it is something simple.
You do not have the required permissions to view the files attached to this post.
TonyD
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: Subform not saving

Unread post by tonyd »

Figured it out! I added a couple of lines to append the "nuEdited" class to each column's element.

Code: Select all

item.children[4].classList.add('nuEdited');
item.children[5].classList.add('nuEdited');
All is right with the world. :D
TonyD
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: Subform not saving

Unread post by admin »

.
Locked