Code snippet in Java Script

I am reading some book of Java Script, but have problem to understand how to use it in Yii. It will be good if You give us some code snippet, often use in application, with comment. This is may way to learn something. Best regards!

I need example in Yii!!!

No, what you need is a basic understanding of JavaScript. Once you have that, you’ll easily see how to use it in Yii (or anywhere else).

Patrick, this isn’t correct!

I am desktop database developer with product on market. Now tray to move on web. I know very clear what I need! This is may way of learning. I have many years experience on others forum to

You don’t wish to help me, so please bypass me!

Asim

Unfortunately the documentation on the client script in Yii is relatively poor.

But the definitive guide shows you how to insert your JavaScript into the page.

http://www.yiiframework.com/doc-2.0/guide-output-client-scripts.html

Just start something like this:




/* in a view script */

$this->registerJs("

$('#test').on('click', function(){

    alert('Clicked!');

});

");


...


<p id="test">Click Me</p>



Note that it’s easier for you to use jQuery rather than vanila JavaScript, since Yii depends heavily on it.

OK softark! I couldn’t understand what is problem to somebody copy 10 examples of standard job when use jquery, with minimal explanation!Anyway thanks! Asim