【问题标题】:How to pass element object instead of id in JSXGraph?如何在 JSXGraph 中传递元素对象而不是 id?
【发布时间】:2015-03-09 13:35:44
【问题描述】:

我正在尝试改变

var brd2 = JXG.JSXGraph.initBoard('box', {boundingbox: [-8.75, 2.5, 8.75, -2.5]});

作为

var brd2 = JXG.JSXGraph.initBoard(this.$('#box'), {boundingbox: [-8.75, 2.5, 8.75, -2.5]});

由于动态元素是在主干视图中创建的,我需要为每个 id 为“box”的元素初始化 JSXGraph。

【问题讨论】:

    标签: javascript backbone.js jsxgraph


    【解决方案1】:

    通过以下 hack,可以将对象而不是 id 传递给 JSXGraph。首先,您需要一个不可见的 div,例如id“虚拟”。然后用这个虚拟 id 初始化电路板,然后我们必须进行更正。让我们进一步假设

    var board = JXG.JSXGraph.initBoard('dummy', {axis:false,
        boundingbox: [-10,30,10,-10], keepaspectratio:false});
    
    var obj = document.getElementById('box'); // or this.$('#box')
    
    board.removeEventHandlers();
    board.container = 'box';
    board.containerObj = obj;
    //
    // Supply the dimensions of the box
    board.renderer = new JXG.SVGRenderer(obj, {width: 800, height: 800});
    board.setBoundingBox([-10,30,10,-10], false);
    board.addEventHandlers();
    

    请注意,在 initBoard() 中指定 axis:truegrid:true 将不起作用。

    希望对您有所帮助, 阿尔弗雷德

    【讨论】:

      猜你喜欢
      • 2020-11-24
      • 2015-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多