Forum

Creating an anchor programmatically?

03 February 2016 09:34
As far as I see, there's no API to neither copy or create an anchor programmatically.
Creating a pool of EMPTY objects and re-using 'em would probably work, but I just wonder if there's at least theoretical possibility to create and dispose anchors via javascript?
03 February 2016 10:22
Hello,

Copying anchors and other EMPTY-objects is really not possible at the moment. We've added this feature to our TODO-list and it will be available in the nearest release or in 16.03.
03 February 2016 12:52
Currently, I decided to temporarily use internal API (approach is not changes-aware, I know):

var m_obj_utils_i = b4w.require("__obj_util");
var m_anchors_i = b4w.require("__anchors");
var m_cons_i = b4w.require("__constraints");

var info = m_obj_utils_i.create_object("info", "EMPTY", "");
    info.anchor = {
        type: "ANNOTATION",
        detect_visibility: false,
        element_id: null,
        max_width: 250
    };
info.render = m_obj_utils_i.create_render("EMPTY");
m_anchors_i.append(info);
03 February 2016 14:28
That's an interesting solution.
Anyway, we'll write about the feature in this thread when it is available.
 
Please register or log in to leave a reply.