On Tue, Sep 14, 2010 at 3:53 PM, Tomfox Wiranata
<[email protected]> wrote:
> ok i admit, i got some problems here understanding...i realize my
> event, that needs to be set, is onClick()
>
> its just hard for me to differentiate, what is actual JS syntax and
> what is just stuff you made up..like this
> "ev.preventDefault(); "

Read the jquery docs. Event handler function is passed the event
object as a param. Its preventDefault() method stops the element the
handler is attached to from doing what it would do by default. In this
case, it will stop the browser from following the link. One does it
this way so that, if JS is disabled, the link points to the correct
place, rather than creating a "javascript link" or setting the href to
"#".

You can also just return false from the function.


> <script id="demo" type="text/javascript">
>
> function requestDelete(name)
> {
>        alert(name);
>        $('#attachments_div').load('deleteattachment', {data: name})
> }
> </script>
> <div id="attachments_div">
>                <?php
>
>                                foreach ($attachments as $attachment):
>
>                                echo $too_many;
>                                echo '<br>';
>
>                                echo $attachment['LinksTmp']['name']; ?>
>
>                                <a onclick="requestDelete('test.jpg')"><img 
> src="../img/icons/
> close.png" /></a>
>
>                     <?php   endforeach;    ?>
>
> </div>
>
> this is the code that is rendered in the view, that is loaded in a
> DIV. as you said, the onClick() event works only after the
> initialization....so how would i adapt that to your proposal?
> i also dont use ajax anymore. so technically we could loose that part
> of your code too, right?

If you're not using AJAX I don't understand what the issue is. In any
case, this is a javascript problem.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to