Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » javascript is not evaluated in right-side CMS panel

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1062 Views
  • karo
    Avatar
    Community Member
    6 Posts

    javascript is not evaluated in right-side CMS panel Link to this post

    hi

    I'm trying to add GoogleMaps feature to client's CMS.
    I'm using both maps module and my own classes.

    I have everything working, except one problem, which i cannot get around for days already.
    For example, i'm successfully using GMapField class to add points to database. I'm using it in a DataObject pop-up window.

    The problem is, i cannot make it work in normal CMS pane (Main tab).

    When i (re)load the whole CMS, the map is there.
    But when i click on (another) page in the tree on left-hand side, displaying another site "page" (in my case a wrapper for a map object), the google map doesn't show.
    I realised the reason is that GMapField is a javascript-generated "field", and javascript doesn't get evaluated when right-hand pane (Main and other tabs) is reloaded. It is evaluated only when the whole CMS window is (re)loaded. In pop-up it works always because it's an iframe, with a freshly loaded document each time.

    So i wrapped the map JS code into a function, and introduced a button to call it; in order to execute the loaded JS in right pane.

    The result? I always get the same map, regardless of which map was clicked in the tree. And the map is the one which was active when CMS was last reloaded.

    In other words, same sh*t - JS got evaluated (and variables assigned values) only on window load; not on right-pane refresh.
    And JS in the refreshed pane is just dead text.

    Can someone please help me solve this in any way?

  • karo
    Avatar
    Community Member
    6 Posts

    Re: javascript is not evaluated in right-side CMS panel Link to this post

    NOTE:
    at first i thought Ajax (via prototype.js) was used to load CMS's right pane; so i set evalScripts:true as a default in prototype's Ajax options object.

    When it didn't help i found out it's not how it works. On CMS's site tree branches there's just normal A HREF tags.
    But i see that although a link may be e.g. "...admin/show/16", the URL in browser stays the same as it was, and just the content pane is reloaded. Sounds like Ajax but it isn't.

    If i would understand how this works, it might help me with my problem.

    So any explanation on this mechanism is also greatly appreciated!

    1062 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.