dcreedy Absent Member.
Absent Member.
151 views

Accessing DOM element within a function

I have an HTML form control with basically the example for a table in
the DG pro doc 5.5.15. I am trying to get a jquery reference to the
table with id='example', but it is not working.

Tried $('#example').dataTable();


What am I missing?

IDM 4.0.2 Patch C

Thank you


Daryl
Labels (1)
0 Likes
5 Replies
Anonymous_User Absent Member.
Absent Member.

Re: Accessing DOM element within a function

Daryl,

$('#example') should give you a handle to the table object - verify with
something like
alert( $('#example').length );

If you are referring to the external "dataTable" library you may need to
include that 3rd party library with your form.

Wolfgang


On 02.01.2014 20:20, Daryl Creedy wrote:
> I have an HTML form control with basically the example for a table in
> the DG pro doc 5.5.15. I am trying to get a jquery reference to the
> table with id='example', but it is not working.
>
> Tried $('#example').dataTable();
>
>
> What am I missing?
>
> IDM 4.0.2 Patch C
>
> Thank you
>
>
> Daryl

0 Likes
dcreedy Absent Member.
Absent Member.

Re: Accessing DOM element within a function

On 1/2/2014 3:06 PM, Wolfgang Schreiber wrote:
> Daryl,
>
> $('#example') should give you a handle to the table object - verify with
> something like
> alert( $('#example').length );
>
> If you are referring to the external "dataTable" library you may need to
> include that 3rd party library with your form.
>
> Wolfgang
>
>
> On 02.01.2014 20:20, Daryl Creedy wrote:
>> I have an HTML form control with basically the example for a table in
>> the DG pro doc 5.5.15. I am trying to get a jquery reference to the
>> table with id='example', but it is not working.
>>
>> Tried $('#example').dataTable();
>>
>>
>> What am I missing?
>>
>> IDM 4.0.2 Patch C
>>
>> Thank you
>>
>>
>> Daryl

The code below is in the HTML content field of the control:

(function () {return "<table id='example'><thead><tr><th>Row
1</th><th>Row
2</th></tr></thead><tbody><tr><td>One</td><td>Two</td></tr><tr><td>Three</td><td>Four</td></tr></tbody></table>";}
) ();

inline script:
//Set Table to Jquery Data Table
$(document).ready(function() {

alert($('#example').length);
});

alert returns 0 for the length.

Thank you
0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Accessing DOM element within a function

Could it be a timing issue and the HTML table not yet be loaded when the
jQuery executes?
You could for example check this from a manually triggered onchange event.

For debugging, the Firefox plugin firebug will show the dynamically
generated HTML code of your loaded form.

Wolfgang


On 02.01.2014 21:22, Daryl Creedy wrote:
> On 1/2/2014 3:06 PM, Wolfgang Schreiber wrote:
>> Daryl,
>>
>> $('#example') should give you a handle to the table object - verify with
>> something like
>> alert( $('#example').length );
>>
>> If you are referring to the external "dataTable" library you may need to
>> include that 3rd party library with your form.
>>
>> Wolfgang
>>
>>
>> On 02.01.2014 20:20, Daryl Creedy wrote:
>>> I have an HTML form control with basically the example for a table in
>>> the DG pro doc 5.5.15. I am trying to get a jquery reference to the
>>> table with id='example', but it is not working.
>>>
>>> Tried $('#example').dataTable();
>>>
>>>
>>> What am I missing?
>>>
>>> IDM 4.0.2 Patch C
>>>
>>> Thank you
>>>
>>>
>>> Daryl

> The code below is in the HTML content field of the control:
>
> (function () {return "<table id='example'><thead><tr><th>Row
> 1</th><th>Row
> 2</th></tr></thead><tbody><tr><td>One</td><td>Two</td></tr><tr><td>Three</td><td>Four</td></tr></tbody></table>";}
> ) ();
>
> inline script:
> //Set Table to Jquery Data Table
> $(document).ready(function() {
>
> alert($('#example').length);
> });
>
> alert returns 0 for the length.
>
> Thank you

0 Likes
dcreedy Absent Member.
Absent Member.

Re: Accessing DOM element within a function

On 01/02/2014 05:20 PM, Wolfgang Schreiber wrote:
> Could it be a timing issue and the HTML table not yet be loaded when the
> jQuery executes?
> You could for example check this from a manually triggered onchange event.
>
> For debugging, the Firefox plugin firebug will show the dynamically
> generated HTML code of your loaded form.
>
> Wolfgang
>
>
> On 02.01.2014 21:22, Daryl Creedy wrote:
>> On 1/2/2014 3:06 PM, Wolfgang Schreiber wrote:
>>> Daryl,
>>>
>>> $('#example') should give you a handle to the table object - verify with
>>> something like
>>> alert( $('#example').length );
>>>
>>> If you are referring to the external "dataTable" library you may need to
>>> include that 3rd party library with your form.
>>>
>>> Wolfgang
>>>
>>>
>>> On 02.01.2014 20:20, Daryl Creedy wrote:
>>>> I have an HTML form control with basically the example for a table in
>>>> the DG pro doc 5.5.15. I am trying to get a jquery reference to the
>>>> table with id='example', but it is not working.
>>>>
>>>> Tried $('#example').dataTable();
>>>>
>>>>
>>>> What am I missing?
>>>>
>>>> IDM 4.0.2 Patch C
>>>>
>>>> Thank you
>>>>
>>>>
>>>> Daryl

>> The code below is in the HTML content field of the control:
>>
>> (function () {return "<table id='example'><thead><tr><th>Row
>> 1</th><th>Row
>> 2</th></tr></thead><tbody><tr><td>One</td><td>Two</td></tr><tr><td>Three</td><td>Four</td></tr></tbody></table>";}
>>
>> ) ();
>>
>> inline script:
>> //Set Table to Jquery Data Table
>> $(document).ready(function() {
>>
>> alert($('#example').length);
>> });
>>
>> alert returns 0 for the length.
>>
>> Thank you


I think it may have more to do with the fact the table is created inside
the anonymous function call. Using firebug and just the function call
to create the table, the table only shows up within the function call.

I can call getElementByID, but I need a jQuery reference, I have tried
different ways to convert but have had no success.

Daryl
0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Accessing DOM element within a function

If you can find the node with getElementByID, you'll also find it with
jQuery. However, your jQuery event wrapper $(document).ready() may fire
too early, so try without that from another event.

Wolfgang


On 03.01.2014 02:51, Daryl Creedy wrote:
> On 01/02/2014 05:20 PM, Wolfgang Schreiber wrote:
>> Could it be a timing issue and the HTML table not yet be loaded when the
>> jQuery executes?
>> You could for example check this from a manually triggered onchange
>> event.
>>
>> For debugging, the Firefox plugin firebug will show the dynamically
>> generated HTML code of your loaded form.
>>
>> Wolfgang
>>
>>
>> On 02.01.2014 21:22, Daryl Creedy wrote:
>>> On 1/2/2014 3:06 PM, Wolfgang Schreiber wrote:
>>>> Daryl,
>>>>
>>>> $('#example') should give you a handle to the table object - verify
>>>> with
>>>> something like
>>>> alert( $('#example').length );
>>>>
>>>> If you are referring to the external "dataTable" library you may
>>>> need to
>>>> include that 3rd party library with your form.
>>>>
>>>> Wolfgang
>>>>
>>>>
>>>> On 02.01.2014 20:20, Daryl Creedy wrote:
>>>>> I have an HTML form control with basically the example for a table in
>>>>> the DG pro doc 5.5.15. I am trying to get a jquery reference to the
>>>>> table with id='example', but it is not working.
>>>>>
>>>>> Tried $('#example').dataTable();
>>>>>
>>>>>
>>>>> What am I missing?
>>>>>
>>>>> IDM 4.0.2 Patch C
>>>>>
>>>>> Thank you
>>>>>
>>>>>
>>>>> Daryl
>>> The code below is in the HTML content field of the control:
>>>
>>> (function () {return "<table id='example'><thead><tr><th>Row
>>> 1</th><th>Row
>>> 2</th></tr></thead><tbody><tr><td>One</td><td>Two</td></tr><tr><td>Three</td><td>Four</td></tr></tbody></table>";}
>>>
>>>
>>> ) ();
>>>
>>> inline script:
>>> //Set Table to Jquery Data Table
>>> $(document).ready(function() {
>>>
>>> alert($('#example').length);
>>> });
>>>
>>> alert returns 0 for the length.
>>>
>>> Thank you

>
> I think it may have more to do with the fact the table is created inside
> the anonymous function call. Using firebug and just the function call
> to create the table, the table only shows up within the function call.
>
> I can call getElementByID, but I need a jQuery reference, I have tried
> different ways to convert but have had no success.
>
> Daryl

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.