Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reasons to call a JS func using JQuery

Status
Not open for further replies.

steve4king

IS-IT--Management
Feb 6, 2007
154
0
0
US
FYI, I'm a complete newb when it comes to JQuery, and pretty new to LAMP dev in general.. so please.. be gentle haha.

I'm updating a web application built on LAMP using PHP, JS, JQuery, Backbone.js, and Yii.

I have a series of buttons(php widget) which call javascript functions.

Some of these call the JS function directly using an onclick property, some do this using just their id to call a jQuery:

Code:
//somefile.php
$this->widget('application.components.buttonGroup.MyButtonGroup', array(
            'items' => array(
                array(
                    'type' => "button",
                    'htmlOptions' => array(
                        'onClick' => 'javascript:csv();',
                    )
                ),
                array(
                    'type' => 'button',
                    'htmlOptions' => array(
                        'id' => 'exportPdf',
                    )
                )
            ),
            'htmlOptions' => array()
        ));
Code:
//somefile.js
$('#runReport').live('click', function () {
    "use strict";
    //do stuff
});
function csv() {
    "use strict";
    //do stuff
}

Does the JQuery call expose properties that the direct JS call does not?

Thanks,


-Stephen
 
jquery is a library created from JS to provide easier manipulaton of the DOM. As such, and like with any framework, jquery has methods and implementations not natively available in JS, but that were built using JS.

So to answer the question, jquery provides access to methods JS does not have directly.

Object properties should remain the same as those are defined by the HTML specification for the elements.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
why is this a php question?

Good point.

For further JS and jQuery questions: forum216


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
<shrug> It's being called from PHP.. and I wasn't sure if there were implications relating to PHP object scope and availability.
Thanks!

-Stephen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top