EasyUI Forum

General Category => Bug Report => Topic started by: iceh on October 10, 2013, 05:12:14 AM



Title: linkbutton('options' fails in .ready() - 1.3.4
Post by: iceh on October 10, 2013, 05:12:14 AM
The following code is automaticually generated.

After loading the form, I get an error:

Uncaught TypeError: Cannot read property 'options' of undefined jquery.easyui.js:810

However, the click event works.

Any idea how i can do this init code? I am looking for a generic approach for all easyui elements.

Thank you.

Code:
<a class="easyui-linkbutton" data-options="iconCls:&#39;icon-search&#39;" id="linkbutton">Link Button</a>
<script type='text/javascript'>
  $('#linkbutton').ready(function () {
    var tmpID =  $('#linkbutton');

    tmpID.ready(function(){ var fkt = function(e) { console.log($('#linkbutton').linkbutton('options').text);  }; fkt( tmpID); });
    tmpID.click(function(e) { console.log($('#linkbutton').linkbutton('options').text); });
  });
</script>


Title: Re: linkbutton('options' fails in .ready() - 1.3.4
Post by: iceh on October 10, 2013, 09:45:27 AM
Ok this is sort of a "bug" but i am not 100% sure how to fix it.

I just learned, that calling "options" isn't a good idea.

But if i call the class default's constructor it's available.

Code:
_tmpID.ready(function(){ var _fktTemp  = function(e) { e.linkbutton(); /* must be called once before the option is available */ console.log(e.linkbutton('options').text);  }; _fktTemp( _tmpID); });


Title: Re: linkbutton('options' fails in .ready() - 1.3.4
Post by: stworthy on October 10, 2013, 06:16:06 PM
If your code is loaded into a container, the <script> runs before $.parser.parse(), this will cause calling 'options' method on a uninitialized link button object. Try the code below to solve this issue.
Code:
<a data-options="iconCls:&#39;icon-search&#39;" id="linkbutton">Link Button</a>
<script type='text/javascript'>
  $('#linkbutton').ready(function () {
    var tmpID =  $('#linkbutton');
    tmpID.linkbutton();
    tmpID.ready(function(){ var fkt = function(e) { console.log($('#linkbutton').linkbutton('options').text);  }; fkt( tmpID); });
    tmpID.click(function(e) { console.log($('#linkbutton').linkbutton('options').text); });
  });
</script>



Title: Re: linkbutton('options' fails in .ready() - 1.3.4
Post by: iceh on October 11, 2013, 01:57:35 AM
Thank you a lot!

Btw. I didn't notice this issue with a 1.2.x Version of EazyUI.