
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2019 10:56 AM
I want to make it available for users to enable/disable the Submit button for each Catalog Item in the SP from the Catalog Item view.
Just like how the Add To Cart button in the SP widget can be enabled/disabled by the No Cart option:
What I managed to understand is that the Add To Cart button is controlled by an ng-if statement
HTML Template:
<button ng-if="c.showAddCartBtn()" name="submit" ng-disabled="submitted" ng-click="triggerAddToCart()" class="btn btn-default">${Add to Cart}</button>
Client Script:
c.showAddCartBtn = function() {
return c.options.show_add_cart_button &&
c.data.sc_cat_item.sys_class_name !== "sc_cat_item_producer" &&
!c.data.sc_cat_item.no_cart;
};
I tried to create my own ng-if statement like c.showSubmitBtn() and a function, but I can't make it work. What would be required to get the same functionality as the No Cart checkbox option but for the Submit button instead?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2019 10:08 AM
I was able to solve it by basically just copying the code for the Order Now functionality:
HTML Template:
<button ng-if="c.showSubmitBtn()" name="submit" ng-disabled="submitted" ng-click="triggerOnSubmit()" class="btn btn-primary">{{submitButtonMsg}}</button>
Client Script
c.showSubmitBtn = function() {
return c.data.sc_cat_item.sys_class_name !== "sc_cat_item_producer" &&
!c.data.sc_cat_item.no_order_now;
};
So now I can enable/disable the submit button by checking/unchecking the No Order Now checkbox in the catalog item view.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2019 12:53 AM
Hi
You can try with ng-disabled
ng-disabled="submitted || (data.required_attachment && !attachments.length)"
This is used to disable the button depending if a checkbox on the catalog item "attachment required" is true or false.
I think that ng-if either shows or hides the button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2019 03:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2019 10:08 AM
I was able to solve it by basically just copying the code for the Order Now functionality:
HTML Template:
<button ng-if="c.showSubmitBtn()" name="submit" ng-disabled="submitted" ng-click="triggerOnSubmit()" class="btn btn-primary">{{submitButtonMsg}}</button>
Client Script
c.showSubmitBtn = function() {
return c.data.sc_cat_item.sys_class_name !== "sc_cat_item_producer" &&
!c.data.sc_cat_item.no_order_now;
};
So now I can enable/disable the submit button by checking/unchecking the No Order Now checkbox in the catalog item view.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 08:16 AM
I removed the following syntax from the client script
c.data.sc_cat_item.sys_class_name !== "sc_cat_item_producer"
so that the Submit button would still show in Record Producers (otherwise they would have no buttons)