locked
LS2013 Html Client: How to change a control's label programmatically? RRS feed

  • Question

  • Hello,

    I need to change the displayable text of several labels that are part of the fields generated by LightSwitch.  Currently, I do the following, and it works properly in IE:

    For example, the following field has a default value of "$$Product$$", which is simply a token that we will replace with some other text.  We use a database lookup for this replacement text, but in the following code, I simply set it to "Product".

    myapp.ViewCustomer.Product_postRender = function (element, contentItem) {
        element.previousSibling.innerText = "Product";
    };

    It depends upon the label being defined just before the data field.  The issue is that this code does not work in FireFox...  So, I am wondering what is the best way to locate a control's label, so I can change its displayable text?

    What is the difference between element.previousSibling and element.previousElementSibling?  When I compare these two fields, they have the same context... The label for the control.

    Thank you for your time and suggestions!

    Mike




    Thursday, December 5, 2013 2:22 PM

Answers

  • I did some differential debugging and discovered that

    element.previousSibling.innerText

    was undefined in FireFox, but it was defined in IE.  I discovered that

    element.previousSibling.textContent

    exists in both browsers, so I've changed my code to use it.  Hope this helps another person...

    Mike

    • Marked as answer by A Bit of Help Thursday, December 5, 2013 4:56 PM
    Thursday, December 5, 2013 4:56 PM

All replies

  • I did some differential debugging and discovered that

    element.previousSibling.innerText

    was undefined in FireFox, but it was defined in IE.  I discovered that

    element.previousSibling.textContent

    exists in both browsers, so I've changed my code to use it.  Hope this helps another person...

    Mike

    • Marked as answer by A Bit of Help Thursday, December 5, 2013 4:56 PM
    Thursday, December 5, 2013 4:56 PM
  • HI Mike

    I’m glad to hear that you have solved this issue by yourself, and it is very appreciated to share your solution to us. It will be helpful for others, and welcome to post your question on Lightswitch forum in your future programming.

    Best regards

    Angie


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 10, 2013 9:12 AM