Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Cannot capture click of a button #6

Open
imrvshah opened this issue Apr 18, 2017 · 10 comments
Open

Cannot capture click of a button #6

imrvshah opened this issue Apr 18, 2017 · 10 comments

Comments

@imrvshah
Copy link

I have text as well as a button on SB-item-header. Now if I want to capture a click of a button it is taking the click of the toggle.

I tried to play with event.preventDefault(); but no luck.

Any leads to getting this click?

@asotog
Copy link
Owner

asotog commented Apr 18, 2017

can you please paste markup here ?

@imrvshah
Copy link
Author

Sorry, didn't include the example.

<squeezebox [multiple]="false">
                <sb-item>
                    <sb-item-head>
                              <span>TEST</span>
                              <button (click)="tempClick()"> </button>
                       </sb-item-head>
                    <sb-item-body>Lorem ipsum dolor</sb-item-body>
                </sb-item>
</squeezebox>

Now, I am trying to capture the event of the button in sb-item-head but I am unable to capture an event.

Hope that makes some sense to you.

@asotog
Copy link
Owner

asotog commented Apr 19, 2017

Don't think is going to work that way, the sb-item-head only receives text as content, under the hood it contains an a tag, if you want to listen when the head is clicked i guess we can update source to make an output method so the head event can be listened, that works for you ? you are also free to contribute with pull request

@imrvshah
Copy link
Author

Yes, You're right. I saw atag in code under the hood. I can make PR but I didn't get what did you mean by

make an output method so the head event can be listened

@asotog
Copy link
Owner

asotog commented Apr 19, 2017

i meant maybe we can have something like:

<squeezebox [multiple]="false">
    <sb-item>
        <sb-item-head (onItemToggled)="tempClick()">Test</sb-item-head>
        <sb-item-body>Lorem ipsum dolor</sb-item-body>
    </sb-item>  
</squeezebox>

@imrvshah
Copy link
Author

Okay Thanks
Let me give a try when I have some time and will create PR.

@imrvshah
Copy link
Author

Well, I got some time to play with it.

What I wanted to do is in the sb-item-header have capabilities to detect button click as well as the tap some other place of the header

This is what the code look like for this

<sb-item-head >
 <test-component [Data]="payment.paymentData (onButtonClick)="buttonDetails($event)">  </test-component>
 </sb-item-head>

You can see here there are two different taps

  1. Click on button which is covered by sb-item-header button
    <a role="button" (click)="toggleClick($event)"><ng-content></ng-content><span class="toggle-icon"></span></a>

  2. onButtonClick() from test-component

Now, if I try to pass my button event click to sb-item-header still it is getting the (click)="toggleClick($event)" as the button is inside the sb-item-header.

@asotog
Copy link
Owner

asotog commented Apr 27, 2017

mm i see will push an update soon maybe that helps you will be an output on each item so you know when the time is toggled

@asotog
Copy link
Owner

asotog commented Apr 28, 2017

@imrvshah code updated please see the outputs section https://github.com/asotog/squeezebox/#outputs

@hahnjas
Copy link

hahnjas commented Jul 20, 2017

I have resolved this for our Angular 4 application by using the following:
<div [innerHTML]="item.description"></div>. This might help others as well ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants