0

i have kinda strange issue here.

i have an item form. on that form i placed a webpart list view. this webpart list view is binded to my item by ID. this ID i placed in a simple input text field.

when i create a new item before it is saved it doesn't have any id. this is why reserve id by ajax call and place this id manually by JS code in this input text field.

here comes crazy stuff.

my webpart doesn't care what's inside this field. it looks in a strange hidden field.

example

<input id="ClientFormPostBackValue_d9b40d1c-cf2b-4100-ad10 d3c6dacac11c_MY-ID-FIELD" name="ClientFormPostBackValue_d9b40d1c-cf2b-4100-ad10-d3c6dacac11c_MY-ID-FIELD" type="hidden" value="MY_RESERVED_ID">

whenever i manually change my ID in my input text field it synchronize value with this hidden field. A-OKEY i tried to change this field also by JS code and it started to work and my webpart list view started to show elements in all browsers EXCEPT Internet Exploer (!).

for god sake, what's wrong with this browser.

I found that i can use CSR for entering ID in this field and using something like this:

ctx.CurrentFieldValue = RESERVED_ID;
SPFieldText_Edit(ctx);

BUT i can't use CSR because i use AJAX for getting this ID.

guys, please help...

UDPATE:

here's my code.

getFuncID("MY-LIST").then(function (data) {
    //reservedID - ID which i got from AJAX
    reservedID = data.d.ReserveListItemId + 1;
    //set value for hidden field. works except IE.
    $('#WPQ2ClientFormPlaceholder').find('input[id$="MY-ID-FIELD"]').attr('value', reservedID );
    ...
});

//AJAX call, using rest call
getFuncID: function (listName) {
        return $.ajax({
            url: "/_api/web/lists/getByTitle('" + listName + "')/reserveListItemId",
            type: "POST",
            headers: {
                "accept": "application/json;odata=verbose",
                "content-type": "application/json;odata=verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val()
            }
        });
    }

UPDATE2:

i found that whenever i manually change value of input text field. it fires some JS code from clientforms.js.

function i() {
    b != null  && a.updateControlValue(a.fieldName, b.value)
}

how to trigger this event through JS. maybe it would help? what do you think?

  • You need to show more code, we need to see where and how you do the ajax call and the callback or promise – Danny '365CSI' Engelman Mar 25 '16 at 7:32
  • @DannyEngelman i added code. please see my update. – Sergey Zykov Mar 25 '16 at 7:47
  • Cool, didn't know about that endpoint. Check the event(s) on the input field. If its a click call it from code with .click()... Have you searched before asking a question!? Please do so next time.. I found this in a minute.. sharepoint.stackexchange.com/questions/112232/… – Danny '365CSI' Engelman Mar 25 '16 at 9:52
  • @DannyEngelman so did i. but something like this doesn't help: $("input[id^='MY-FIELD']").trigger("change") or $("input[id^='MY-FIELD']").trigger("blur") or $("input[id^='MY-FIELD']").change() what i miss? – Sergey Zykov Mar 25 '16 at 9:56
  • Then trace what JS is called in the event and call it yourself. If it is a jQuery syntax problem.. sorry can't help there... I develop without using jQuery – Danny '365CSI' Engelman Mar 25 '16 at 10:59
1

seems i solved it. by that code i was inserting an attribute but not an actual value:

$('#WPQ2ClientFormPlaceholder').find('input[id$="MY-ID-FIELD"]').attr('value', reservedID );

it's enough for all browsers except IE.

For making it work on IE you also need to insert an actual value for the input:

$('#WPQ2ClientFormPlaceholder').find('input[id$="MY-ID-FIELD"]').val(reservedID );

answer was close ^_^

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.