none
ListView - prevent items from get deselected on Button click RRS feed

  • Question

  • Hi there,

    I place Code Editor web part on AllItems.aspx page with following code:

    <button type='button' onclick='test();return false;' >test</button>
    <script>
    function test() {
    //nothing here
    }
    </script>

    Now, when I select item rows in list view and click this button afterwards all selection disappear. How can I avoid that?

    PS I cannot change <button> element to <input>


    • Edited by paspaspas Wednesday, April 12, 2017 6:52 AM
    Wednesday, April 12, 2017 6:49 AM

All replies

  • Hi,

    As a workaround, we can add the code into AllItems.aspx page using SharePoint designer 2013.

    <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
    
    <button type='button' onclick='test();return false;' >test</button>
    <script type="text/javascript">
    function test() {
      console.log("test dennis");
    }
    </script>
    
    </asp:Content>

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, April 13, 2017 8:22 AM
    Moderator
  • Nope, already have button. Need it behave like input.
    Thursday, April 13, 2017 12:06 PM
  • Hi,

    We just copy all the code in content editor web part into AllItem.aspx page using SharePoint designer.

    Or we have to use <input type="button" id="mybtn" onclick="test();return false;" value="test"/> to instead the <button/>.

    Or please provide more information about why don't you want to use input button.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, April 14, 2017 1:44 AM
    Moderator