从circle元素中获取类

时间:2016-06-18 14:25:57

标签: meteor d3.js spacebars

我正在使用d3来渲染代表我数据库中每个元素的圆圈。每个圈子看起来都像这样:

<circle r="8" fill="#585858" stroke="#008db7" stroke-width="3" id="Node;R6AnePqKecNNe7dkr" class="R6AnePqKecNNe7dkr"></circle>

点击任意一个圈子后,我可以使用以下内容返回“成功”:

Template.tree.events({
  'click circle': function(){
    console.log("success")
  }
}); 

但我不想“成功”,而是要返回点击的圆圈类。

如果我是console.log(这个),我得到'对象{}',所以我的直觉告诉我使用this.class,但这不会返回任何内容。

1 个答案:

答案 0 :(得分:1)

在答案here中找到,以下代码解决了问题

Function exportData_Click()

    ' Declare Variables        
    Dim strSaveFileName As String
    Dim The_Year As Variant
    Dim ctlCurrentControl As Control
    Dim surveyName As String, allData As String, effort As String
    Dim fileYear As String

    Dim fd As Object
    Const msoFileDialogFolderPicker = 4
    Dim strFolderPath

    ' Get the name of the control button clicked (corresponds to query name to be run)
    Set ctlCurrentControl = Screen.ActiveControl
    surveyName = ctlCurrentControl.Name
    allData = surveyName & "AllData"
    effort = surveyName & "Effort_Export"

    ' Get combobox value and assign relavent values to The_Year
    The_Year = Forms![Extract Data]!Extract_Year.Value

    ' Change the year from a variant to what we need in the SQL
    If The_Year Like "20*" Then
        The_Year = CInt(The_Year)
        fileYear = The_Year
    Else:
        The_Year = "*"
        fileYear = "All"
    End If

    ' Set queryYear variable
    setYear (The_Year)

    ' Folder Pick Dialog
    Set fd = Application.FileDialog(msoFileDialogFolderPicker)

    With fd
        .Title = "Browse for folder to export queries"
        .AllowMultiSelect = False
        .Filters.Clear
        If .Show = -1 Then
            strFolderPath = .SelectedItems(1)
        Else
            'The user pressed Cancel.
            MsgBox "No folder Selected", vbExclamation
            strFolderPath = Null
            Set fd = Nothing
            Exit Function
        End If
    End With

    Set fd = Nothing

    ' Export functions for different survey cases
    If surveyName Like "*O*_" Then
        strSaveFileName = strFolderPath & "\" & allData & ".xlsx"
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, allData, strSaveFileName

    ElseIf surveyName Like "*DA_" Then
        strSaveFileName = strFolderPath & "\" & surveyName & ".xlsx"
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, surveyName & "Occ_export", strSaveFileName
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, surveyName & "Trees_export", strSaveFileName
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, surveyName & "RepTree_export", strSaveFileName
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, surveyName & "Habitat_export", strSaveFileName
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, surveyName & "TPole_export", strSaveFileName

    Else
        strSaveFileName = strFolderPath & "\" & allData & ".xlsx"
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, allData, strSaveFileName
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, effort, strSaveFileName
    End If

End Function