EasyUI Forum
March 28, 2024, 02:01:06 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: linkbutton('options' fails in .ready() - 1.3.4  (Read 13889 times)
iceh
Jr. Member
**
Posts: 61


View Profile
« 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>
Logged
iceh
Jr. Member
**
Posts: 61


View Profile
« Reply #1 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); });
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 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>

Logged
iceh
Jr. Member
**
Posts: 61


View Profile
« Reply #3 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.

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!