Hi,
I have two questions.
#First
How to pass value from html to javascript? Currently I'm doing like this :
My javascript :
Ext.onReady(function() {
var image = Ext.get('show-win');
image.on('click', function(r) {
Ext.Msg.alert('Status', r.target.alt);
});
My html :
But I don't like this method because I'm passing value through 'alt' tag.Is there any way other than this method?
#Second
From my above codes, I would like to trigger image.on('click', function(r) {.... from a href (text link).Any idea?
Thank!
Hi,
Thanks for your help.But unfotunately I don't get what do you mean.Is it like this ? :
PHP :
getResult() as $value) {?>
getid() ?>" style="cursor: pointer;" />
Javascript :
Ext.onReady(function(r) {
Ext.select('img.popup').on('click', function(r) {
Ext.Msg.alert('Status', r.target.id);
});
Really need your help.Thanks again!
1) If you're binding the event handler to the image, at that point don't you already know what the alt text is going to be? If you don't, how you're doing it isn't necessarily that bad, the other option would be setting up some kind of mapping, like:
var values = {};
values['show-win'] = 'This is the value';
Ext.onReady(function() {
Ext.fly('show-win').on('click', function(e) { Ext.Msg.alert('Status', values[e.getTarget().id]); });
});
2) Not quite sure what you mean here?
I got now! It's now work! This is my final solution :
My PHP
getResult() as $value) {?>
getid() ?>" style="cursor: pointer;" />
My Javascript
Ext.onReady(function() {
Ext.select('img.test').on('click', function(r) {
Ext.Msg.alert('Status', r.target.id);
});
Thanks Evant!
For the first issue, you could assign each image a classname, then use:
Ext.select('img.popup').on('click', ....);
For the second, the same thing applies, just select the element and apply an onclick handler.
Hi,
Thanks for your fast reply!
What I want try to do is,I want to launch MsgAlert for each link through loop that I created using php :
getResult() as $value) {?>
getid() ?>" style="cursor: pointer;" />
..and this is the javascript
Ext.onReady(function(r) {
var image = Ext.get(What id?);
image.on('click', function(r) {
Ext.Msg.alert('Status', r.target.id);
});
My problem is what 'id' to pass to Ext.get(What id?); because my id is unique and generated at runtime by php.
#Second
For second issue,instead of clicking image,I want to show MsgAlert when clicking text (example normal link)
Thanks!
Red Hat's Rough Recovery From CFO Exit
Windows Live Finds a New, Pre-installed Home
|