Announcement

Collapse
No announcement yet.

How to get rid of "Display web version" in mobile version of form

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get rid of "Display web version" in mobile version of form

    This message displays on any form viewed on a mobile screen. I need to get rid of it so I checked the id from inspect element and send some JS code to hide it in onAppInit. Alas the console always says the element with that id does not exist. I'm very sure the spelling is right because it is by cut and paste. How else can this message be eliminated?

  • #2
    The console is probably right, at that point in time there probably is no element with that ID because they probably create it at the moment that they show it which makes it not be there in the onLoad.
    Basically you'll have to make an event to listen to what gets added, checks whether the ID is right then does what you want to do with it, now there are some ways....

    Option #1:
    Using setTimeout to fire the delete code a bit later. Definitely the easiest however I wouldn't really support doing this.
    Option #2:
    Using .live from jquery, basically something like shown here: jsfiddle.net/rcMhq/
    This is said to have been deprecaded since jQuery 1.8.+ however in JSFiddle it still works on 1.8.3 and I believe Scriptcase uses 1.8.2 so you might still be able to use it but whenever they update their jQuery (maybe sometime.... ah who am i kidding) you'd have to update your code.
    Option #3:
    Using MutationObservers as shown on this site: updates.html5rocks.com/2012/02/Detect-DOM-changes-with-Mutation-Observers
    However support wise you might miss some stuff: caniuse.com/#feat=mutationobserver
    For some more information/another example on this go here: developer.mozilla.org/en/docs/Web/API/MutationObserver
    Above link shows browser compatibility too but I love caniuse....
    Now I suppose I'd have to recommend using mutationobservers but if it doesn't support browsers (however I suppose this'd only apply to the mobile browsers as it doesn't matter whether it works on old desktop browsers or not) you need to support.

    Comment


    • #3
      [INDENT]Using MutationObservers as shown on this site: updates.html5rocks.com/2012/02/Detect-DOM-changes-with-Mutation-Observers

      Very interesting. So at this link I see: document.addEventListener("DOMNodeInserted", function(e) {...

      How then do I detect the specific insertion of this specific element by id...as in what do I put in the quotes?

      Comment


      • #4
        Originally posted by scriptcaser View Post
        [INDENT]Using MutationObservers as shown on this site: updates.html5rocks.com/2012/02/Detect-DOM-changes-with-Mutation-Observers

        Very interesting. So at this link I see: document.addEventListener("DOMNodeInserted", function(e) {...

        How then do I detect the specific insertion of this specific element by id...as in what do I put in the quotes?
        Ok found this https://github.com/rafaelw/mutation-...PIReference.md. Will study closely, thank you

        Comment


        • #5
          Hmm, the domnodeinsterted event listener is part of the deprecated code tha got replace by mutation observers, the example below that is the one with the actual new code however for your situation taking a look at mozilla's documentation and example is probably easier.
          After taking a bit longer look at it it's actually rather complicated, err I'll see if I have some free time to try and put some code together soonish. Don't really have the time atm though.

          Just took a quick peek at the github project, it looks about the same.
          Far as I'm getting from it you want to put the target as the div or whatever wraps (has to be there when you create the target) around the thing you want to remove than get the .childList from that whenever it changes in the event , loop through the childlist and see whether what you want to remove is in there, if it is remove it.

          Comment


          • #6
            Originally posted by hoihoi661 View Post
            Hmm, the domnodeinsterted event listener is part of the deprecated code tha got replace by mutation observers, the example below that is the one with the actual new code however for your situation taking a look at mozilla's documentation and example is probably easier.
            After taking a bit longer look at it it's actually rather complicated, err I'll see if I have some free time to try and put some code together soonish. Don't really have the time atm though.

            Just took a quick peek at the github project, it looks about the same.
            Far as I'm getting from it you want to put the target as the div or whatever wraps (has to be there when you create the target) around the thing you want to remove than get the .childList from that whenever it changes in the event , loop through the childlist and see whether what you want to remove is in there, if it is remove it.
            You mean it's not as simple as:

            var observer = new MutationSummary({
            callback: { document.getelementbyId("theID").visible = false; } //not sure this is the right js code; just for illustration
            queries: [
            {element: "#theID"}
            ]
            });

            (my cursory understanding of https://github.com/rafaelw/mutation-...PIReference.md)

            If it is, is MutationSummary automatically a known class (in supported browsers) or a js script file needs to be included?

            Comment


            • #7
              Not normally no, Mutation Observer is part of the standard JS. However Mutation Summary isn't, it's an object made by those people (on github) which you can include in your projects. (they use mutation observers btw, they just make the usage easier)
              It shouldn't be too hard without including that JS library, but I don't really have the time to search through the Mutation Observer API at the moment, sorry.

              Comment


              • #8
                Followed a suggestion to achieve this with css and it worked.

                Thanx!

                Comment


                • #9
                  Oh yeh suppose CSS works too, guess I divert to using JS too quick before looking at other options. Anyways glad you figured something out.

                  Comment

                  Working...
                  X