Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed inline JavaScript from template #4141

Closed
wants to merge 1 commit into from

Conversation

pivulic
Copy link
Contributor

@pivulic pivulic commented Apr 13, 2016

Problem

Difficult to extend the catalogAddToCart widget due to Inline JavaScript, something you strongly are against to according to: http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/js_init.html

@orlangur
Copy link
Contributor

I didn't try to understand this logic deeply but it looks like your changes changed the semantics.

Before that only for

<?php if ($block->isRedirectToCartEnabled()) : ?>

false condition this initialization occured.

Also, product/view/form template received knowledge about addToCart which is not correct. Should be done within initial template similar to positive branch of {{if}}:

<script type="text/x-magento-init">
    {
        "#product_addtocart_form": {
            "Magento_Catalog/product/view/validation": {
                "radioCheckboxClosest": ".nested"
            }
        }
    }
</script>

@daim2k5
Copy link
Contributor

daim2k5 commented Apr 16, 2016

@pivulic Thank you for your contribution. Please accept the contributors license agreement so this PR can be further processed. This can be done by clicking the "Details" link next to the "license/cla" check below.

@pivulic
Copy link
Contributor Author

pivulic commented Apr 16, 2016

I have now clicked the Details link and accepted the license. But here it says I still haven't, maybe a temporary glitch?

Not sure what you meant @orlangur, could you maybe commit your changes the way you think it should be? The idea is basically to remove the Inline JavaScript from addtocart.phtml

@daim2k5
Copy link
Contributor

daim2k5 commented Apr 16, 2016

@pivulic maybe because your githib email adress is not public? Maybe you can check...

@piotrekkaminski
Copy link
Contributor

Internal issue MAGETWO-53439

@orlangur
Copy link
Contributor

orlangur commented May 27, 2016

@pivulic, I'm not going to rework this code, just tried to describe why current changes seem doubtful to me.

So here is an example of correct inline JavaScript elimination in this file: f191737#diff-bcc11b36af8eaf52078666d9755945beL46 (note that there is still <script> tag but the code became declarative)

Here is where if condition was introduced: 7c1abf6#diff-bcc11b36af8eaf52078666d9755945beL48

Correct implementation should result in two declarative <script> blocks in both branches of if statement within app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml file, without hardcoding of addtocart into app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml file and without <?php if ($block->isRedirectToCartEnabled()) : ?> logic breakage.

/cc @guz-anton

@guz-anton
Copy link
Contributor

HI @pivulic ,
As you can find we abandon your fix but issue got an attention.

First of all we made usage catalogAddToCart alias, second fix was proper declarative initialization.

Please review if suitable for you. Current PR I close. Fill free to comment if any notice you have.

@guz-anton guz-anton closed this Jun 8, 2016
@pivulic
Copy link
Contributor Author

pivulic commented Jun 8, 2016

Nice!

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

Successfully merging this pull request may close these issues.

6 participants