Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Ext User
    Join Date
    Mar 2009
    Posts
    34
    Vote Rating
    0
    altamirador is on a distinguished road

      0  

    Default calling a function defined within Ext.OnReady

    calling a function defined within Ext.OnReady


    Hi to all !

    In a recent post, I had a problem with the method Confirm from which I was not able to "read" back the value clicked (yes or no).

    As I suspected, the problem was beetween my two ears. I was not using the Onready method to define the functions I was using. Now, I'm getting somewhere...and nowhere at the same time !

    Here is my very straightforward code:

    Ext.onReady(function(){

    function DelPart(vPartID) {
    Ext.MessageBox.confirm( 'Delete this part ? :' + vPartID , showResult);
    };

    function showResult(btn){
    if (btn == 'yes') {
    (...) delete the part (...)
    };
    };
    });

    In theory, this code is valid.

    However, I cannot find a way to call the DelPart function from within html like so:

    <img id="Delete" src="../images/delete.png" width="11" height="11" onClick="DelPart(12341);">

    Doing a debug with Firebug, It says it cannot find the function DelPart because it's undefined. I know it's undefined because it's being defined within OnReady but I do I get to call it ??

    Thanks for your help!

    Altamirador

  2. #2
    Sencha User
    Join Date
    Feb 2009
    Posts
    29
    Vote Rating
    0
    Warebear is on a distinguished road

      0  

    Default


    Have you tried to simply make it just a <script> in the head of your HTML?

    Code:
    <script language='JavaScript'>
      function DelPart(vPartID) {
                    Ext.Msg.alert('Deleting...', 'Delete this part?', function(btn){
                        if (btn == 'ok'){
                        .....delete code.....
                        }                
                    });
                    }
    </script>


    If you have the right links to the libraries and such you don't need the on ready function that I know of.

  3. #3
    Sencha - Community Support Team VinylFox's Avatar
    Join Date
    Mar 2007
    Location
    Baltimore, MD
    Posts
    1,501
    Vote Rating
    7
    VinylFox will become famous soon enough VinylFox will become famous soon enough

      0  

    Default


    Or better yet, use Ext to attach a click handler to your image.

    Code:
    Ext.onReady(function(){
    
    	function DelPart(vPartID){
    		Ext.MessageBox.confirm('Delete this part ? :' + vPartID, showResult);
    	};
    	
    	function showResult(btn){
    		if (btn == 'yes') {
    			//(...) delete the part (...)
    		};
    	};
    	
    	Ext.get('Delete').on('click', DelPart);
    	
    });
    An example of this is used in the "hello world" demo included with the example code.

    http://www.extjs.com/deploy/dev/exam...indow/hello.js


    PS. Your error has to do with scope - I would suggest reading up on it.

  4. #4
    Ext User
    Join Date
    Mar 2009
    Posts
    34
    Vote Rating
    0
    altamirador is on a distinguished road

      0  

    Default calling a function defined within Ext.OnReady

    calling a function defined within Ext.OnReady


    Here is my code:

    Ext.onReady(function(){

    function showResult(btn){
    if (btn == 'yes') {
    alert('sssss');
    };
    Ext.example.msg('Button Click', 'You clicked the {0} button', btn);
    };

    function DelPart(vStuID, vStudName) {
    stu_no_id = vStuID;
    Ext.MessageBox.confirm('<?php echo $RetirerListe ?>', <?php echo "'$RetirerListe2<b>' + vStudName + '</b>$RetirerListe3'" ?> , showResult);


    };


    I need to be able to call the DelPart function from HTML like this:


    onClick="DelPart(11, 'Pat Burns')"


    Unfortunately, the DelPart function remains unknown ??

    Any ideas ?

    Thanks !

  5. #5
    Ext User
    Join Date
    Mar 2009
    Posts
    34
    Vote Rating
    0
    altamirador is on a distinguished road

      0  

    Default calling a function defined within Ext.OnReady

    calling a function defined within Ext.OnReady


    Here is my code:

    Ext.onReady(function(){

    function showResult(btn){
    if (btn == 'yes') {
    alert('sssss');
    };
    Ext.example.msg('Button Click', 'You clicked the {0} button', btn);
    };

    function DelPart(vStuID, vStudName) {
    stu_no_id = vStuID;
    Ext.MessageBox.confirm('<?php echo $RetirerListe ?>', <?php echo "'$RetirerListe2<b>' + vStudName + '</b>$RetirerListe3'" ?> , showResult);


    };


    I need to be able to call the DelPart function from HTML like this:


    onClick="DelPart(11, 'Pat Burns')"


    Unfortunately, the DelPart function remains unknown ??

    Any ideas ?

    Thanks !

  6. #6
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    http://extjs.com/learn/Ext_Forum_Hel..._code_properly

    Read about closures in javascript, to understand the scope issue you have. Numerous ways to resolve it, depends on what you want to do. Maybe a namespace would be appropriate. You don't have to include function definitions inside onReady as they won't be executed until you call them.

  7. #7
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,711
    Vote Rating
    104
    mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all

      0  

    Default


    That isn't exactly a good way to handle events. Look in the examples section and see how you can grab any html element and then attach a listener to it. If you want to go down your road try:

    Code:
    Ext.onReady(function(){
    
    function showResult(btn){
    if (btn == 'yes') {
    alert('sssss');
    };
    Ext.example.msg('Button Click', 'You clicked the {0} button', btn);
    };
    
    window.DelPart = function(vStuID, vStudName) {
    stu_no_id = vStuID;
    Ext.MessageBox.confirm('<?php echo $RetirerListe ?>', <?php echo "'$RetirerListe2<b>' + vStudName + '</b>$RetirerListe3'" ?> , showResult);
    
    
    };

  8. #8
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    671
    Vote Rating
    20
    carol.ext will become famous soon enough carol.ext will become famous soon enough

      0  

    Default


    Why do you keep posting this same question over and over? Please stop.

  9. #9
    Ext User
    Join Date
    Mar 2009
    Posts
    34
    Vote Rating
    0
    altamirador is on a distinguished road

      0  

    Default Yep I know

    Yep I know


    The problem is this...

    If I do not put my function inside OnReady and I test the value of BTN, it always return "1".

    I read that this is because the value is not "ready" when I read it ??

    So I'm trying to resolve this by including it in OnReady and calling the DelPart function from HTML.

    Any ideas ?

  10. #10
    Ext User
    Join Date
    Mar 2009
    Posts
    34
    Vote Rating
    0
    altamirador is on a distinguished road

      0  

    Default


    Because everyone keeps answering the same way and it does not work ! Instead of telling me to stop, could you be "constructive" and help solve my problem. Actually, it's on ly my 2nd or 3rd post. I really don't think I'm abusing !